Exemple #1
0
 public void Reset()
 {
     InUse     = false;
     Current   = null;
     m_current = m_list.First;
     m_version = m_list.Version;
 }
Exemple #2
0
        private void CacheNode(LALinkedListNode <TYPE> node)
        {
            node.Value = null;
            node.Next  = null;

            if (m_cache.Count < MaxCacheSize)
            {
                m_cache.Add(node);
            }
        }
Exemple #3
0
        public bool MoveNext()
        {
            if (m_version != m_list.Version)
            {
                throw new InvalidOperationException("Collection was modified after the enumerator was insantiated");
            }

            if (m_current == null)
            {
                InUse = false;
                return(false);
            }
            else
            {
                Current   = m_current.Value;
                m_current = m_current.Next;
                return(true);
            }
        }
Exemple #4
0
        public void Remove(TYPE item)
        {
            Version++;

            if (Count == 0)
            {
                return;
            }

            if (item == First.Value)
            {
                RemoveFirst();
            }
            else if (item == Last.Value)
            {
                RemoveLast();
            }
            {
                LALinkedListNode <TYPE> previous = null;
                LALinkedListNode <TYPE> current  = First;

                while (current != null)
                {
                    if (item == current.Value)
                    {
                        previous.Next = current.Next;
                        Count--;

                        CacheNode(current);
                        return;
                    }

                    previous = current;
                    current  = current.Next;
                }
            }
        }
Exemple #5
0
 public LALinkedListEnumerator(LALinkedList <TYPE> list)
 {
     m_list    = list;
     m_current = list.First;
     m_version = list.Version;
 }