public Iter GetIter3(long field3)
        {
            if (index3.IsBlank())
            {
                BuildIndex3();
            }
            uint hashcode = Miscellanea.Hashcode((uint)field3);

            return(new Iter(Tuple.Empty, Tuple.Empty, (uint)field3, index3.Head(hashcode), Iter.Type.F3, this));
        }
        public Iter GetIter1(long field1)
        {
            if (index1.IsBlank())
            {
                BuildIndex1();
            }
            uint hashcode = Miscellanea.Hashcode((uint)field1);

            return(new Iter((uint)field1, Tuple.Empty, Tuple.Empty, index1.Head(hashcode), Iter.Type.F1, this));
        }
        public Iter GetIter2(long field2)
        {
            if (index2.IsBlank())
            {
                BuildIndex2();
            }
            uint hashcode = Miscellanea.Hashcode((uint)field2);

            return(new Iter(Tuple.Empty, (uint)field2, Tuple.Empty, index2.Head(hashcode), Iter.Type.F2, this));
        }
        void BuildIndex3()
        {
            uint len = (uint)tuples.Length;

            index3.Init(len);
            for (uint i = 0; i < len; i++)
            {
                Tuple tuple = tuples[i];
                if (tuple.field2OrEmptyMarker != Tuple.Empty)
                {
                    index3.Insert(i, Miscellanea.Hashcode(tuple.field3));
                }
            }
        }
        public bool Contains12(uint field1, uint field2)
        {
            uint hashcode = Miscellanea.Hashcode(field1, field2);

            for (uint idx = index12.Head(hashcode); idx != Tuple.Empty; idx = index12.Next(idx))
            {
                Tuple tuple = tuples[idx];
                if (tuple.field1OrNext == field1 & tuple.field2OrEmptyMarker == field2)
                {
                    return(true);
                }
            }
            return(false);
        }
        public bool Contains(long field1, long field2, long field3)
        {
            uint hashcode = Miscellanea.Hashcode((uint)field1, (uint)field2, (uint)field3);

            for (uint idx = index123.Head(hashcode); idx != Tuple.Empty; idx = index123.Next(idx))
            {
                Tuple tuple = tuples[idx];
                if (tuple.field1OrNext == field1 & tuple.field2OrEmptyMarker == field2 & tuple.field3 == field3)
                {
                    return(true);
                }
            }
            return(false);
        }
        public void Delete(uint field1, uint field2, uint field3)
        {
            uint hashcode = Miscellanea.Hashcode(field1, field2, field3);

            for (uint idx = index123.Head(hashcode); idx != Tuple.Empty; idx = index123.Next(idx))
            {
                Tuple tuple = tuples[idx];
                if (tuple.field1OrNext == field1 & tuple.field2OrEmptyMarker == field2 & tuple.field3 == field3)
                {
                    DeleteAt(idx, hashcode);
                    return;
                }
            }
        }
        public bool Contains3(uint field3)
        {
            if (index3.IsBlank())
            {
                BuildIndex3();
            }
            uint hashcode = Miscellanea.Hashcode(field3);

            for (uint idx = index3.Head(hashcode); idx != Tuple.Empty; idx = index3.Next(idx))
            {
                Tuple tuple = tuples[idx];
                if (tuple.field3 == field3)
                {
                    return(true);
                }
            }
            return(false);
        }
        public bool Contains2(uint field2)
        {
            if (index2.IsBlank())
            {
                BuildIndex2();
            }
            uint hashcode = Miscellanea.Hashcode(field2);

            for (uint idx = index2.Head(hashcode); idx != Tuple.Empty; idx = index2.Next(idx))
            {
                Tuple tuple = tuples[idx];
                if (tuple.field2OrEmptyMarker == field2)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #10
0
        ////////////////////////////////////////////////////////////////////////////

        void DeleteAt(uint index, uint hashcode)
        {
            Tuple tuple = tuples[index];

            Miscellanea.Assert(tuple.field2OrEmptyMarker != Tuple.Empty);

            // Removing the tuple
            tuples[index].field1OrNext        = firstFree;
            tuples[index].field2OrEmptyMarker = Tuple.Empty;
            Miscellanea.Assert(tuples[index].field1OrNext == firstFree);
            Miscellanea.Assert(tuples[index].field2OrEmptyMarker == Tuple.Empty);
            firstFree = index;
            count--;

            // Updating the indexes
            index123.Delete(index, hashcode);
            index12.Delete(index, Miscellanea.Hashcode(tuple.field1OrNext, tuple.field2OrEmptyMarker));
            if (!index13.IsBlank())
            {
                index13.Delete(index, Miscellanea.Hashcode(tuple.field1OrNext, tuple.field3));
            }
            if (!index23.IsBlank())
            {
                index23.Delete(index, Miscellanea.Hashcode(tuple.field2OrEmptyMarker, tuple.field3));
            }
            if (!index1.IsBlank())
            {
                index1.Delete(index, Miscellanea.Hashcode(tuple.field1OrNext));
            }
            if (!index2.IsBlank())
            {
                index2.Delete(index, Miscellanea.Hashcode(tuple.field2OrEmptyMarker));
            }
            if (!index3.IsBlank())
            {
                index3.Delete(index, Miscellanea.Hashcode(tuple.field3));
            }

            // Updating the reference count in the value stores
            store1.Release(tuple.field1OrNext);
            store2.Release(tuple.field2OrEmptyMarker);
            store3.Release(tuple.field3);
        }
Exemple #11
0
        public Iter GetIter12(long field1, long field2)
        {
            uint hashcode = Miscellanea.Hashcode((uint)field1, (uint)field2);

            return(new Iter((uint)field1, (uint)field2, Tuple.Empty, index12.Head(hashcode), Iter.Type.F12, this));
        }
Exemple #12
0
        public void Insert(uint field1, uint field2, uint field3)
        {
            if (Contains(field1, field2, field3))
            {
                return;
            }

            // Increasing the size of the table if need be
            if (firstFree >= tuples.Length)
            {
                uint size = (uint)tuples.Length;
                Miscellanea.Assert(count == size);
                Tuple[] newTuples = new Tuple[2 * size];
                Array.Copy(tuples, newTuples, size);
                for (uint i = size; i < 2 * size; i++)
                {
                    newTuples[i].field1OrNext        = i + 1;
                    newTuples[i].field2OrEmptyMarker = Tuple.Empty;
                    Miscellanea.Assert(newTuples[i].field1OrNext == i + 1);
                    Miscellanea.Assert(newTuples[i].field2OrEmptyMarker == Tuple.Empty);
                }
                tuples = newTuples;
                index123.Reset();
                index12.Reset();
                index13.Reset();
                index23.Reset();
                index1.Reset();
                index2.Reset();
                index3.Reset();
                BuildIndex123();
                BuildIndex12();
            }

            // Inserting the new tuple
            uint index = firstFree;

            firstFree     = tuples[firstFree].field1OrNext;
            tuples[index] = new Tuple(field1, field2, field3);
            count++;

            // Updating the indexes
            index123.Insert(index, Miscellanea.Hashcode(field1, field2, field3));
            index12.Insert(index, Miscellanea.Hashcode(field1, field2));
            if (!index13.IsBlank())
            {
                index13.Insert(index, Miscellanea.Hashcode(field1, field3));
            }
            if (!index23.IsBlank())
            {
                index23.Insert(index, Miscellanea.Hashcode(field2, field3));
            }
            if (!index1.IsBlank())
            {
                index1.Insert(index, Miscellanea.Hashcode(field1));
            }
            if (!index2.IsBlank())
            {
                index2.Insert(index, Miscellanea.Hashcode(field2));
            }
            if (!index3.IsBlank())
            {
                index3.Insert(index, Miscellanea.Hashcode(field3));
            }

            // Updating the reference count in the value stores
            store1.AddRef(field1);
            store2.AddRef(field2);
            store3.AddRef(field3);
        }