예제 #1
0
 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);
 }
예제 #2
0
        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);
        }
예제 #3
0
 public DoubleLinkedList(T t) : this()
 {
     m_Head.Next  = new DoubleLinkedListNode <T>(t);
     m_Tail       = m_Head.Next;
     m_Tail.Prior = m_Head;
 }
예제 #4
0
 public DoubleLinkedList()
 {
     m_Head  = new DoubleLinkedListNode <T>();
     m_Tail  = m_Head;
     m_Count = 0;
 }