Ejemplo n.º 1
0
        private void SetValue(TKey key, TValue value)
        {
            var hashKey = GetHashKey(key);
            var items   = _table[hashKey];

            if (items == null)
            {
                items           = new MyOneWayLinkedList <MyKeyValuePair <TKey, TValue> >();
                _table[hashKey] = items;
            }
            else
            {
                var node = items.First;

                while (node != null)
                {
                    if (node.Value.Key.Equals(key))
                    {
                        items.Remove(node);
                        break;
                    }

                    node = node.Next;
                }
            }

            items.AddLast(new MyKeyValuePair <TKey, TValue>
            {
                Key   = key,
                Value = value
            });
        }
Ejemplo n.º 2
0
 public MyHashtable()
 {
     _capacity = 1000;
     _table    = new MyOneWayLinkedList <MyKeyValuePair <TKey, TValue> > [_capacity];
 }