Exemplo n.º 1
0
        private void FixHashTable()
        {
            ChainPart[] FixedTable = new ChainPart[Height * 2];

            for (int i = 0; i < Height; i++)
            {
                ChainPart Current = Table[i];
                while (Current != null)
                {
                    K Currentkey = Current.key;
                    FixedTable[Hash(Currentkey, Height * 2)] = new ChainPart(Currentkey, Table[i].value, FixedTable[Hash(Currentkey, Height * 2)]);

                    Current = Current.next;
                }
            }
            this.Table = FixedTable;
        }
Exemplo n.º 2
0
        public static void BaiscChain()
        {
            //The non-generic chain is an implementation of Chain<Guid>
            //which uses DefaultVertexFactory, DefaultEdgeFactory and DefaultIdentityProvider
            Chain chainHelper = new Chain();

            //The identity type must be specified because type inference can't help here
            ChainInfo <Guid> chain = chainHelper.Create(10, false);

            //Can get the vertex at the start of the chain from the chain info
            ChainPart <Guid> start = chain.StartOfChain;

            //Can navigate through the chain using NextVertex property
            //The vertex itself is the Vertex property
            Vertex <Guid> nextVertex = start.NextVertex.Vertex;

            //Can get the graph representing the chain from the Graph property
            Graph <Guid> chainGraph = chain.Graph;
        }
Exemplo n.º 3
0
        public void Insert(K key, V value)
        {
            int       HashKey = Hash(key, this.Height);
            ChainPart current = Table[HashKey];

            while (current != null)
            {
                if (current.key.Equals(key))
                {
                    Console.WriteLine("Already exist.");
                    return;
                }
                current = current.next;
            }
            ++Count;
            Table[HashKey] = new ChainPart(key, value, Table[HashKey]);

            if (LoadFactor >= 1.5)
            {
                FixHashTable();
            }
        }
Exemplo n.º 4
0
 public ChainPart(K key, V value, ChainPart last)
 {
     this.key   = key;
     this.value = value;
     next       = last;
 }