Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        public void Remove(int var, int low, int high)
        {
            HPosition pos = GenerateKey(var, low, high);

            while (!Null(pos.cluster.Cluster[pos.offset]))
            {
                if (pos.cluster.Cluster[pos.offset].var == var && pos.cluster.Cluster[pos.offset].low == low && pos.cluster.Cluster[pos.offset].high == high)
                {
                    count--;
                    pos.cluster.Cluster[pos.offset] = HEntry.DirtyEntry();     //Only flags dirty
                    return;
                }
                IncreaseKey(ref pos);
            }
        }
Exemplo n.º 3
0
        public void Add(HEntry entry)
        {
#if NoGC
            if (NeedResize())
            {
                AddCluster();
            }
#endif
            HPosition pos = GenerateKey(entry.var, entry.low, entry.high);
            while (Used(pos.cluster.Cluster[pos.offset]))
            {
                IncreaseKey(ref pos);
            }
            pos.cluster.Cluster[pos.offset] = entry;
            count++;
        }
Exemplo n.º 4
0
 public bool Dirty(HEntry entry)
 {
     return(entry.low == -1);
 }
Exemplo n.º 5
0
 public bool Used(HEntry entry)
 {
     return(entry.var > 0 || entry.u > 0);
 }
Exemplo n.º 6
0
 public bool Null(HEntry entry)
 {
     return(entry.var == 0 && entry.u == 0);
 }