Beispiel #1
0
        public void AddCluster()
        {
            HCluster NewCluster = new HCluster(this.size);

            size = (int)(size * factor);

            NewCluster.next   = this.FirstCluster;              //New cluster is added in the beginning
            this.FirstCluster = NewCluster;

            HPosition pos = new HPosition(ref FirstCluster.next, 0);

            while (!(pos.cluster == FirstCluster && pos.offset == 0))      //rehash
            {
                if (Used(pos.cluster.Cluster[pos.offset]))
                {
                    HEntry    entry       = pos.cluster.Cluster[pos.offset];
                    HPosition newPosition = GenerateKey(entry.var, entry.low, entry.high);

                    if (newPosition.offset != pos.offset || newPosition.cluster != pos.cluster)
                    {
                        pos.cluster.Cluster[pos.offset] = HEntry.DirtyEntry();
                        this.count--;
                        Add(entry);
                    }
                }

                IncreaseKey(ref pos);
            }
        }
Beispiel #2
0
 public void Clear(int size)
 {
     this.FirstCluster = new HCluster(size);
     this.startSize    = size;
     this.size         = size;
     this.count        = 0;
 }
Beispiel #3
0
        //splits a key into cluster + offset
        internal HPosition GenerateKey(int var, int low, int high)
        {
            int      offset = (int)(Triple(var, low, high) % (ulong)size);
            HCluster probe  = FirstCluster;

            while (offset >= probe.Cluster.Length)
            {
                offset -= probe.Cluster.Length;
                probe   = probe.next;
            }

            return(new HPosition(ref probe, offset));
        }
Beispiel #4
0
 internal HPosition(ref HCluster cluster, int offset)
 {
     this.cluster = cluster;
     this.offset  = offset;
 }