コード例 #1
0
        public int Recount()
        {
            int length = 0;
            LinkListItem <T> pointer = _first;

            while (pointer != null)
            {
                length++;
                pointer = pointer.Next;
            }
            return(length);
        }
コード例 #2
0
        public T Pop()
        {
            var listItem = _first;

            if (listItem == null)
            {
                return(default(T));
            }
            _first = _first.Next;
            if (_first != null)
            {
                _first.Prev = null;
            }
            _length--;
            return(listItem.Element);
        }
コード例 #3
0
 public int Add(T element)
 {
     if (_length == 0)
     {
         _last = _first = new LinkListItem <T> {
             Element = element, Prev = null, Next = null
         };
     }
     else
     {
         _last = _last.Next = new LinkListItem <T> {
             Element = element, Prev = _last, Next = null
         };
     }
     return(++_length);
 }