Ejemplo n.º 1
0
 internal Link(ET o, java.util.LinkedList.Link <ET> p, java.util.LinkedList.Link <ET
                                                                                  > n)
 {
     data     = o;
     previous = p;
     next     = n;
 }
Ejemplo n.º 2
0
 internal LinkIterator(java.util.LinkedList <ET> @object, int location)
 {
     list             = @object;
     expectedModCount = list.modCount;
     if (location >= 0 && location <= list._size)
     {
         // pos ends up as -1 if list is empty, it ranges from -1 to
         // list.size - 1
         // if link == voidLink then pos must == -1
         link = list.voidLink;
         if (location < list._size / 2)
         {
             for (pos = -1; pos + 1 < location; pos++)
             {
                 link = link.next;
             }
         }
         else
         {
             for (pos = list._size; pos >= location; pos--)
             {
                 link = link.previous;
             }
         }
     }
     else
     {
         throw new System.IndexOutOfRangeException();
     }
 }
Ejemplo n.º 3
0
 public void remove()
 {
     if (expectedModCount == list.modCount)
     {
         if (lastLink != null)
         {
             java.util.LinkedList.Link <ET> next_1     = lastLink.next;
             java.util.LinkedList.Link <ET> previous_1 = lastLink.previous;
             next_1.previous = previous_1;
             previous_1.next = next_1;
             if (lastLink == link)
             {
                 pos--;
             }
             link     = previous_1;
             lastLink = null;
             expectedModCount++;
             list._size--;
             list.modCount++;
         }
         else
         {
             throw new System.InvalidOperationException();
         }
     }
     else
     {
         throw new java.util.ConcurrentModificationException();
     }
 }
Ejemplo n.º 4
0
 internal ReverseLinkIterator(LinkedList <E> _enclosing, java.util.LinkedList <ET> linkedList
                              )
 {
     this._enclosing       = _enclosing;
     this.list             = linkedList;
     this.expectedModCount = this.list.modCount;
     this.link             = this.list.voidLink;
     this.canRemove        = false;
 }
Ejemplo n.º 5
0
 public virtual ET next()
 {
     if (this.expectedModCount == this.list.modCount)
     {
         if (this.hasNext())
         {
             this.link      = this.link.previous;
             this.canRemove = true;
             return(this.link.data);
         }
         throw new java.util.NoSuchElementException();
     }
     throw new java.util.ConcurrentModificationException();
 }
Ejemplo n.º 6
0
 public ET previous()
 {
     if (expectedModCount == list.modCount)
     {
         if (link != list.voidLink)
         {
             lastLink = link;
             link     = link.previous;
             pos--;
             return(lastLink.data);
         }
         throw new java.util.NoSuchElementException();
     }
     throw new java.util.ConcurrentModificationException();
 }
Ejemplo n.º 7
0
 public ET next()
 {
     if (expectedModCount == list.modCount)
     {
         java.util.LinkedList.Link <ET> next_1 = link.next;
         if (next_1 != list.voidLink)
         {
             lastLink = link = next_1;
             pos++;
             return(link.data);
         }
         throw new java.util.NoSuchElementException();
     }
     throw new java.util.ConcurrentModificationException();
 }
Ejemplo n.º 8
0
        public override bool addAll <_T0> (int location, Collection <_T0> collection)
        {
            if (location < 0 || location > _size)
            {
                throw new System.IndexOutOfRangeException();
            }
            int adding = collection.size();

            if (adding == 0)
            {
                return(false);
            }
            Collection <_T0> elements = (collection == this) ? new ArrayList <_T0> (collection)
                                : (java.util.Collection <_T0>)collection;

            java.util.LinkedList.Link <E> previous = voidLink;
            if (location < (_size / 2))
            {
                {
                    for (int i = 0; i < location; i++)
                    {
                        previous = previous.next;
                    }
                }
            }
            else
            {
                {
                    for (int i = _size; i >= location; i--)
                    {
                        previous = previous.previous;
                    }
                }
            }
            LinkedList.Link <E> next = previous.next;
            foreach (E e in Sharpen.IterableProxy.Create(elements))
            {
                LinkedList.Link <E> newLink = new LinkedList.Link <E> (e, previous, null);
                previous.next = newLink;
                previous      = newLink;
            }
            previous.next = next;
            next.previous = previous;
            _size        += adding;
            modCount++;
            return(true);
        }
Ejemplo n.º 9
0
 public void add(ET @object)
 {
     if (expectedModCount == list.modCount)
     {
         java.util.LinkedList.Link <ET> next_1  = link.next;
         java.util.LinkedList.Link <ET> newLink = new java.util.LinkedList.Link <ET>(@object
                                                                                     , link, next_1);
         link.next       = newLink;
         next_1.previous = newLink;
         link            = newLink;
         lastLink        = null;
         pos++;
         expectedModCount++;
         list._size++;
         list.modCount++;
     }
     else
     {
         throw new java.util.ConcurrentModificationException();
     }
 }
Ejemplo n.º 10
0
 public virtual void remove()
 {
     if (this.expectedModCount == this.list.modCount)
     {
         if (this.canRemove)
         {
             java.util.LinkedList.Link <ET> next_1   = this.link.previous;
             java.util.LinkedList.Link <ET> previous = this.link.next;
             next_1.next       = previous;
             previous.previous = next_1;
             this.link         = previous;
             this.list._size--;
             this.list.modCount++;
             this.expectedModCount++;
             this.canRemove = false;
             return;
         }
         throw new System.InvalidOperationException();
     }
     throw new java.util.ConcurrentModificationException();
 }