public DoubleLinkListDictionaryNode(TKey key, TValue value, DoubleLinkListDictionaryNode <TKey, TValue> next) { Next = next; Key = key; Value = value; if (Next != null) { Next.Previous = this; } }
private void Touch(DictionaryNode node) { RemoveNode(node); node.Next = _firstNode; if (_firstNode != null) { _firstNode.Previous = node; } _firstNode = node; }
// ************************************************************************ // Subset of IDictionary<TKey, TValue> Members // ************************************************************************ #region Subset of IDictionary<TKey, TValue> Members /// <summary> /// Adds an element with the provided key and value to the IDictionary<TKey, TValue>. /// </summary> /// <param name="key"> /// The object to use as the key of the element to add. /// </param> /// <param name="value"> /// The object to use as the value of the element to add. /// </param> public virtual TValue Add(TKey key, TValue value) { DictionaryNode node = new DictionaryNode(key, value, _firstNode); _keyToIndex.Add(key, node); _firstNode = node; if (_lastNode == null) { _lastNode = node; } return(value); }
private void RemoveNode(DoubleLinkListDictionaryNode <TKey, TValue> node) { if (node == _lastNode) { _lastNode = node.Previous; } if (node == _firstNode) { _firstNode = node.Next; } if (node.Next != null) { node.Next.Previous = node.Previous; } if (node.Previous != null) { node.Previous.Next = node.Next; } node.Next = null; node.Previous = null; }
/// <summary> /// Removes all items from the ICollection<T>. /// </summary> public virtual void Clear() { _keyToIndex.Clear(); _lastNode = null; }
public DictionaryNode(TKey key, TValue value, DoubleLinkListDictionaryNode <TKey, TValue> next) : base(key, value, next) { }