Пример #1
0
        public override void Store(string name, object value)
        {
            int num = hash(name);

            if (vals[num] == null)
            {
                vals[num] = new Node(name, value);
            }
            else
            {
                Node temp = vals[num];
                Node prev = null;
                bool done = false;
                while (temp != null)
                {
                    if (temp.getKey() == name)
                    {
                        temp.setPair(name, value);
                        done = true;
                    }
                    prev = temp;
                    temp = temp.getNext();
                }
                if (!done)
                {
                    prev.setNext(new Node(name, value));
                }
            }
            count++;
        }
Пример #2
0
        public override void Store(string key, object value)
        {
            Node temp = head;
            Node prev = temp;

            if (head == null)
            {
                head = new Node(key, value);
                length++;
                return;
            }
            while (temp != null)
            {
                if (temp.getKey() == key)
                {
                    temp.setPair(key, value);
                    return;
                }
                prev = temp;
                temp = temp.getNext();
            }
            prev.setNext(new Node(key, value));
            length++;
        }