Esempio n. 1
0
        internal CompoundIndex addCompound(Compound compound)
        {
            CompoundIndex compoundIndex = CompoundIndex.make((uint)compounds.Count);

            compounds.Add(compound);

            compoundIdToCompoundIndex[compound.compoundId] = compoundIndex;

            termRefererIdToCompound[compound.thisTermReferer.getMaskedOutId] = compound;



            // add it to the hashtables
            compound.updateHashes();
            compoundHashtableByWithId.insert(compoundIndex);
            compoundHashtableByWithoutId.insert(compoundIndex);

            return(compoundIndex);
        }
Esempio n. 2
0
        // checks if the compound exists and returns the index of the compound if it is the case
        // the compoundId is not used for hash lookup/comparision
        internal bool existsCompoundWithoutCompoundId(Compound compoundToCompareWithoutCompoundId, out CompoundIndex foundCompoundIndex)
        {
            foundCompoundIndex = CompoundIndex.makeInvalid();

            if (!compoundHashtableByWithoutId.existHash(compoundToCompareWithoutCompoundId.cachedHashWithoutCompoundId))
            {
                return(false);
            }

            ulong[] potentialCompoundIndices = getPotentialIndicesOfCompoundsByHashWithoutCompoundId(compoundToCompareWithoutCompoundId.cachedHashWithoutCompoundId);

            // compare and search the compound which matches the queried one
            foreach (var iCompoundIndex in potentialCompoundIndices)
            {
                Compound iCompound = compounds[(int)iCompoundIndex];
                if (Compound.isEqualWithoutCompoundIdAndTermReferer(compoundToCompareWithoutCompoundId, iCompound))
                {
                    foundCompoundIndex = CompoundIndex.make((/*quick and dirty conversation*/ (uint)iCompoundIndex));
                    return(true);
                }
            }

            return(false);
        }