예제 #1
0
        public void Add(T item)
        {
            var newNode = new LooselyLinkedListNode <T>(item);

            last.Next = newNode;
            last      = newNode;
        }
예제 #2
0
        public static LooselyLinkedListNode <T> CreateDummyFor(LooselyLinkedListNode <T> node)
        {
            var dummy = new LooselyLinkedListNode <T>(default(T));

            dummy.Next = node;
            return(dummy);
        }
예제 #3
0
 public void CutAfter(LooselyLinkedListNode <T> node)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     node.Next = null;
     last      = node;
 }
예제 #4
0
        public void AddAfter(LooselyLinkedListNode <T> node, LooselyLinkedListNode <T> newNode)
        {
            if (newNode == null)
            {
                throw new ArgumentNullException("newNode");
            }
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            var lastNew = newNode;

            while (lastNew.Next != null)
            {
                lastNew = lastNew.Next;
            }
            if (node == last)
            {
                last = lastNew;
            }
            lastNew.Next = node.Next;
            node.Next    = newNode;
        }
예제 #5
0
 public void Add(LooselyLinkedListNode <T> newNode)
 {
     AddAfter(last, newNode);
 }
예제 #6
0
 public void Reset()
 {
     current = first;
 }
예제 #7
0
 public bool MoveNext()
 {
     current = current.Next;
     return(current != null);
 }
예제 #8
0
 public Enumerator(LooselyLinkedListNode <T> first)
 {
     this.current = first;
     this.first   = first;
 }
예제 #9
0
 public LooselyLinkedList()
 {
     first = new LooselyLinkedListNode <T>(default(T));
     last  = first;
 }
예제 #10
0
 public void Clear()
 {
     first.Next = null;
     last       = first;
 }
예제 #11
0
 public void AddFirst(LooselyLinkedListNode <T> newNode)
 {
     AddAfter(first, newNode);
 }
예제 #12
0
 public void AddAfter(LooselyLinkedListNode <T> node, T value)
 {
     AddAfter(node, new LooselyLinkedListNode <T>(value));
 }