void advance()
 {
     if (depth >= 0)
     {
         int npos = stackpos[depth] + 1;
         if (npos < stack[depth].Length)
         {
             stackpos[depth] = npos;
             BasicNode elem = stack[depth][npos];
             if (elem is SNode <K, V> )
             {
                 current = (SNode <K, V>)elem;
             }
             else if (elem is INode <K, V> )
             {
                 readin((INode <K, V>)elem);
             }
         }
         else
         {
             depth -= 1;
             advance();
         }
     }
     else
     {
         current = null;
     }
 }
Exemplo n.º 2
0
        public void TestSetKVNodeValue()
        {
            KVNode testNode4 = new KVNode("cat", "dog");

            testNode4.Value = "NewValue";
            Assert.Equal("NewValue", testNode4.Value);
        }
Exemplo n.º 3
0
        public void TestSetKVNodeKey()
        {
            KVNode testNode2 = new KVNode("cat", "dog");

            testNode2.Key = "NewKey";
            Assert.Equal("NewKey", testNode2.Key);
        }
        private void readin(INode <K, V> _in)
        {
            MainNode <K, V> m = _in.gcasRead(ct);

            if (m is CNode <K, V> )
            {
                CNode <K, V> cn = (CNode <K, V>)m;
                depth          += 1;
                stack[depth]    = cn.array;
                stackpos[depth] = -1;
                advance();
            }
            else if (m is TNode <K, V> )
            {
                current = (TNode <K, V>)m;
            }
            else if (m is LNode <K, V> )
            {
                subiter = ((LNode <K, V>)m).listmap.iterator();
                checkSubiter();
            }
            else if (m == null)
            {
                current = null;
            }
        }
Exemplo n.º 5
0
        public void TestGetCurrentLL()
        {
            KVNode         testNode11 = new KVNode("cat", "dog");
            KVNodeLinkList testKVLL3  = new KVNodeLinkList();

            testKVLL3.Current = testNode11;
            Assert.Equal(testNode11, testKVLL3.Current);
        }
Exemplo n.º 6
0
        public void TestSetHeadLL()
        {
            KVNode         testNode10 = new KVNode("cat", "dog");
            KVNodeLinkList testKVLL2  = new KVNodeLinkList();

            testKVLL2.Head = testNode10;
            Assert.Equal(testNode10, testKVLL2.Head);
        }
Exemplo n.º 7
0
        public void TestGetKVNodeNext()
        {
            KVNode testNode5 = new KVNode("cat", "dog");
            KVNode testNode6 = new KVNode("red", "blue");

            testNode5.Next = testNode6;
            Assert.Equal(testNode6, testNode5.Next);
        }
Exemplo n.º 8
0
        public void TestSetKVNodeNext()
        {
            KVNode testNode7 = new KVNode("cat", "dog");
            KVNode testNode8 = new KVNode("red", "blue");
            KVNode testNode9 = new KVNode("apple", "banana");

            testNode7.Next = testNode8;
            testNode7.Next = testNode9;
            Assert.Equal(testNode9, testNode7.Next);
        }
Exemplo n.º 9
0
        public void TestLLAppend()
        {
            KVNodeLinkList testKVLL8 = new KVNodeLinkList();

            testKVLL8.Insert("cat", "dog");
            KVNode testNode14 = new KVNode("apple", "pear");

            testKVLL8.Append(testNode14);
            Assert.Equal("apple", testKVLL8.Head.Next.Key);
        }
Exemplo n.º 10
0
        public void TestSetCurrentLL()
        {
            KVNode         testNode12 = new KVNode("cat", "dog");
            KVNode         testNode13 = new KVNode("cat", "dog");
            KVNodeLinkList testKVLL4  = new KVNodeLinkList();

            testKVLL4.Current = testNode12;
            testKVLL4.Current = testNode13;
            Assert.Equal(testNode13, testKVLL4.Current);
        }
Exemplo n.º 11
0
        //methods
        /// <summary>
        /// Adds a new key value pair to hash table
        /// </summary>
        /// <param name="key">the key</param>
        /// <param name="value">the value</param>
        public void AddToHashTable(string key, string value)
        {
            int hashIndex = Hash(key);

            if (HashTableArray[hashIndex] == null)
            {
                KVNodeLinkList tempLL = new KVNodeLinkList();
                HashTableArray[hashIndex] = tempLL;
                HashTableArray[hashIndex].Insert(key, value);
            }
            else
            {
                KVNode newNode = new KVNode(key, value);
                HashTableArray[hashIndex].Append(newNode);
            }
        }
Exemplo n.º 12
0
        public void TestGetKVNodeValue()
        {
            KVNode testNode3 = new KVNode("cat", "dog");

            Assert.Equal("dog", testNode3.Value);
        }
Exemplo n.º 13
0
        public void TestGetKVNodeKey()
        {
            KVNode testNode1 = new KVNode("cat", "dog");

            Assert.Equal("cat", testNode1.Key);
        }