Beispiel #1
0
 public override void Insert(int index, object value)
 {
     if ((index < 0) || (index > base.Count))
     {
         throw new ArgumentOutOfRangeException("index");
     }
     if (base.Count == 0)
     {
         base.proot = new Node(value, null);
     }
     else if (index == 0)
     {
         base.proot = new Node(value, base.proot);
     }
     else if (index == base.Count)
     {
         this.GetNode(base.Count - 1).Next = new Node(value, null);
     }
     else
     {
         ILinkNode node = this.GetNode(index - 1);
         ILinkNode next = node.Next;
         node.Next = new Node(value, next);
     }
     base.plastIndex++;
 }
Beispiel #2
0
 internal LinkEnumerator(Link link)
 {
     if (link == null)
     {
         throw new ArgumentNullException("link");
     }
     this._link    = link;
     this._index   = -1;
     this._current = null;
 }
Beispiel #3
0
        /// <summary>
        /// 输出链表里的内容
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="link"></param>
        public static void ShowList <T>(this ILinkNode <T> link)
        {
            LinkNode <T> node = link.node;

            while (node != null)
            {
                Console.WriteLine(node.data);
                node = node.next;
            }
        }
Beispiel #4
0
 public static void Remove(this ILinkNode source)
 {
     if (source.GetPrev() != null)
     {
         source.GetPrev().SetNext(source.GetNext());
     }
     if (source.GetNext() != null)
     {
         source.GetNext().SetPrev(source.GetPrev());
     }
     source = null;
 }
Beispiel #5
0
 public static void CutOff(this ILinkNode source)
 {
     if (source.GetPrev() != null)
     {
         source.GetPrev().SetNext(null);
     }
     if (source.GetNext() != null)
     {
         source.GetNext().SetPrev(null);
     }
     source = null;
 }
Beispiel #6
0
 protected internal virtual ILinkNode GetNode(int index)
 {
     if ((index < 0) || (index >= this.Count))
     {
         throw new ArgumentOutOfRangeException("index");
     }
     ILinkNode proot = this.proot;
     for (int i = 0; i < index; i++)
     {
         proot = proot.Next;
     }
     return proot;
 }
Beispiel #7
0
        protected internal virtual ILinkNode GetNode(int index)
        {
            if ((index < 0) || (index >= this.Count))
            {
                throw new ArgumentOutOfRangeException("index");
            }
            ILinkNode proot = this.proot;

            for (int i = 0; i < index; i++)
            {
                proot = proot.Next;
            }
            return(proot);
        }
Beispiel #8
0
        public int IndexOf(object value)
        {
            ILinkNode proot = this.proot;

            for (int i = 0; i < this.Count; i++)
            {
                if (proot.Value == value)
                {
                    return(i);
                }
                proot = proot.Next;
            }
            return(-1);
        }
Beispiel #9
0
 public bool MoveNext()
 {
     if (this._index >= (this._link.Count - 1))
     {
         return(false);
     }
     if (this._index++ == -1)
     {
         this._current = this._link.GetNode(0);
     }
     else
     {
         this._current = this._current.Next;
     }
     return(true);
 }
Beispiel #10
0
        public override void RemoveAt(int index)
        {
            if ((index < 0) || (index >= base.Count))
            {
                throw new ArgumentNullException("index");
            }
            ILinkNode next = this.GetNode(index).Next as Node;

            if (index > 0)
            {
                this.GetNode(index - 1).Next = next;
            }
            else
            {
                base.proot = next;
            }
            base.plastIndex--;
        }
Beispiel #11
0
        public void CopyTo(Array array, int index)
        {
            if (array == null)
            {
                throw new ArgumentNullException("array");
            }
            if ((index < 0) || (index >= this.Count))
            {
                throw new ArgumentOutOfRangeException("index");
            }
            if (array.Length < (this.Count - index))
            {
                throw new ArgumentOutOfRangeException("array is of insufficient size.");
            }
            ILinkNode next = this.GetNode(index);

            for (int i = index; i < this.Count; i++)
            {
                array.SetValue(next.Value, (int)(index - (index - i)));
                next = next.Next;
            }
        }
Beispiel #12
0
 public Node(object value, ILinkNode next) : base(value, next)
 {
 }
Beispiel #13
0
 protected LinkNode(object value, ILinkNode next)
 {
     this._value = value;
     this._next  = next;
 }
 protected LinkNode(object value, ILinkNode next)
 {
     this._value = value;
     this._next = next;
 }
Beispiel #15
0
 public void Reset()
 {
     this._index = -1;
     this._current = null;
 }
Beispiel #16
0
 public void Clear()
 {
     this.plastIndex = 0;
     this.proot = null;
     GC.Collect();
 }
Beispiel #17
0
 public static void AddPrev(this ILinkNode source, ILinkNode value)
 {
     value.SetNext(source);
     source.SetPrev(value);
 }
Beispiel #18
0
 public bool MoveNext()
 {
     if (this._index >= (this._link.Count - 1))
     {
         return false;
     }
     if (this._index++ == -1)
     {
         this._current = this._link.GetNode(0);
     }
     else
     {
         this._current = this._current.Next;
     }
     return true;
 }
Beispiel #19
0
 public int IndexOf(object value)
 {
     ILinkNode proot = this.proot;
     for (int i = 0; i < this.Count; i++)
     {
         if (proot.Value == value)
         {
             return i;
         }
         proot = proot.Next;
     }
     return -1;
 }
Beispiel #20
0
 public void SetPrev(ILinkNode value)
 {
     InRect.State = value == null ? 0 : 2;
     Prev         = value;
 }
Beispiel #21
0
 public void Clear()
 {
     this.plastIndex = 0;
     this.proot      = null;
     GC.Collect();
 }
Beispiel #22
0
 public void Reset()
 {
     this._index   = -1;
     this._current = null;
 }
Beispiel #23
0
 public void SetNext(ILinkNode value)
 {
     OutRect.State = value == null ? 0 : 2;
     Next          = value;
 }
Beispiel #24
0
 public Node(object value, ILinkNode previous, ILinkNode next) : base(value, next)
 {
     this._previous = previous;
 }
 public Node(object value, ILinkNode previous, ILinkNode next) : base(value, next)
 {
     this._previous = previous;
 }
Beispiel #26
0
 public static void AddNext(this ILinkNode source, ILinkNode value)
 {
     source.SetNext(value);
     value.SetPrev(source);
 }
 public Node(object value, ILinkNode next) : base(value, next)
 {
 }
Beispiel #28
0
 internal LinkEnumerator(Link link)
 {
     if (link == null)
     {
         throw new ArgumentNullException("link");
     }
     this._link = link;
     this._index = -1;
     this._current = null;
 }