public KeyValuePair <K, V>[] Add(K key, V value) { KeyValuePair <K, V>[] rm = null; lock (this) { DoubleLinkedListNode <K> v = _queue.AddHead(key); //O(1) _dict[key] = new DictItem() { Node = v, Value = value }; //O(1) rm = checkAndTruncate(); } return(rm); }
public DoubleLinkedListNode <T> AddHead(T t) { DoubleLinkedListNode <T> insertNode = new DoubleLinkedListNode <T>(t); DoubleLinkedListNode <T> currentNode = m_Head; insertNode.Prior = null; insertNode.Next = currentNode; currentNode.Prior = insertNode; m_Head = insertNode; m_Count++; if (m_Count == 1) { m_Tail = m_Head; } return(insertNode); }
public DoubleLinkedList(T t) : this() { m_Head.Next = new DoubleLinkedListNode <T>(t); m_Tail = m_Head.Next; m_Tail.Prior = m_Head; }
public DoubleLinkedList() { m_Head = new DoubleLinkedListNode <T>(); m_Tail = m_Head; m_Count = 0; }