コード例 #1
0
        public T Current(DoubleLinkedListEnumerator <T> enumerator)
        {
            if (enumerator.Index == 0 || (enumerator.Index == enumerator.List.Count + 1))
            {
                throw XExceptions.InvalidOperation.EnumOpCantHappen();
            }

            return(enumerator.Current);
        }
コード例 #2
0
        public void Reset(DoubleLinkedListEnumerator <T> enumerator)
        {
            if (enumerator.Version != enumerator.List.Version)
            {
                throw XExceptions.InvalidOperation.EnumFailedVersion();
            }

            enumerator.Current = default(T);
            enumerator.Node    = enumerator.List.Head;
            enumerator.Index   = 0;
        }
コード例 #3
0
        public DoubleLinkedListEnumerator <T> Create(DoubleLinkedList <T> collection)
        {
            var enumerator = new DoubleLinkedListEnumerator <T>
            {
                List    = collection,
                Version = collection.Version,
                Node    = collection.Head,
                Current = default(T),
                Index   = 0,
                SiInfo  = null
            };

            return(enumerator);
        }
コード例 #4
0
        public bool MoveNext(DoubleLinkedListEnumerator <T> enumerator)
        {
            if (enumerator.Version != enumerator.List.Version)
            {
                throw XExceptions.InvalidOperation.EnumFailedVersion();
            }

            if (enumerator.Node == null)
            {
                enumerator.Index = enumerator.List.Count + 1;
                return(false);
            }

            ++enumerator.Index;
            enumerator.Current = enumerator.Node.Value;
            enumerator.Node    = enumerator.Node.Next;
            if (enumerator.Node == enumerator.List.Head)
            {
                enumerator.Node = null;
            }
            return(true);
        }
コード例 #5
0
 public void Dispose(DoubleLinkedListEnumerator <T> enumerator)
 {
     enumerator.Current = default(T);
     enumerator.List    = null;
 }