Exemple #1
0
        void Mark(int u)
        {
            TPosition pos = GenerateKey(u);

            while (!Null(pos.cluster.Cluster[pos.offset]))
            {
                if (pos.cluster.Cluster[pos.offset].u == u)
                {
                    break;
                }
                IncreaseKey(ref pos);
            }
            TEntry entry = GetTEntry(pos);

            if (entry.GetMark() != true)
            {
                if (!IsTerminal(entry.low))
                {
                    Mark(entry.low);
                }

                AddMark(ref pos);

                if (!IsTerminal(entry.high))
                {
                    Mark(entry.high);
                }
            }
        }
Exemple #2
0
        private void AddCluster()
        {
            TCluster NewCluster = new TCluster(this.size);

            size = (int)(size * this.factor);

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

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

            while (!(pos.cluster == FirstCluster && pos.offset == 0))      //rehash
            {
                if (Used(pos.cluster.Cluster[pos.offset]))
                {
                    TEntry    entry       = pos.cluster.Cluster[pos.offset];
                    TPosition newPosition = GenerateKey(entry.u);

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

                IncreaseKey(ref pos);
            }
        }
Exemple #3
0
        public IEnumerator GetEnumerator()
        {
            TPosition pos = new TPosition(ref FirstCluster, 0);

            while (!pos.IsLastPosition())
            {
                if (Used(pos.cluster.Cluster[pos.offset]))
                {
                    yield return(pos.cluster.Cluster[pos.offset]);
                }
                IncreaseKey(ref pos);
            }
        }
Exemple #4
0
        void UnMark(int u)
        {
            TPosition pos = GenerateKey(u);

            while (!Null(pos.cluster.Cluster[pos.offset]))
            {
                if (pos.cluster.Cluster[pos.offset].u == u)
                {
                    pos.cluster.Cluster[pos.offset].SetMark(false);
                    break;
                }
                IncreaseKey(ref pos);
            }
        }
Exemple #5
0
        public bool ContainsKey(int u)
        {
            TPosition pos = GenerateKey(u);

            while (!Null(pos.cluster.Cluster[pos.offset]))
            {
                if (pos.cluster.Cluster[pos.offset].u == u)
                {
                    return(true);
                }
                IncreaseKey(ref pos);
            }
            return(false);
        }
Exemple #6
0
        public void Remove(int u)
        {
            TPosition pos = GenerateKey(u);

            while (!Null(pos.cluster.Cluster[pos.offset]))
            {
                if (pos.cluster.Cluster[pos.offset].u == u)
                {
                    count--;
                    pos.cluster.Cluster[pos.offset] = TEntry.DirtyEntry();     //Only flags dirty
                    return;
                }
                IncreaseKey(ref pos);
            }
        }
Exemple #7
0
        public void Add(TEntry entry)
        {
#if NoGC
            if (NeedResize())
            {
                AddCluster();
            }
#endif
            TPosition pos = GenerateKey(entry.u);
            while (Used(pos.cluster.Cluster[pos.offset]))
            {
                IncreaseKey(ref pos);
            }
            pos.cluster.Cluster[pos.offset] = entry;
            count++;
        }
Exemple #8
0
 internal void IncreaseKey(ref TPosition position)
 {
     position.offset++;
     if (position.cluster.Cluster.Length == position.offset) //treat array as a cycle
     {
         position.offset = 0;
         if (position.cluster.IsLastCluster())
         {
             position.cluster = this.FirstCluster;
         }
         else
         {
             position.cluster = position.cluster.next;
         }
     }
 }
Exemple #9
0
        public BddNode this[int u]
        {
            get
            {
                TPosition pos = GenerateKey(u);
                while (!Null(pos.cluster.Cluster[pos.offset]))
                {
                    if (pos.cluster.Cluster[pos.offset].u == u)
                    {
                        return(new BddNode(pos.cluster.Cluster[pos.offset].low, pos.cluster.Cluster[pos.offset].high, pos.cluster.Cluster[pos.offset].GetVar()));
                    }

                    IncreaseKey(ref pos);
                }
                return(new BddNode(0, 0, 0));
            }
        }
Exemple #10
0
 void AddMark(ref TPosition pos)
 {
     pos.cluster.Cluster[pos.offset].SetMark(true);
 }
Exemple #11
0
 private static TEntry GetTEntry(TPosition pos)
 {
     return(pos.cluster.Cluster[pos.offset]);
 }