Remove and return first n elements on the linked list of all elements.

@return first element
496148
public List<T> pollN(int n) {
    if (n >= size) {
      return pollAll();
    }
    List<T> retList = new ArrayList<T>(n);
    if (n == 0) {
      return retList;
    }
    boolean done = false;
    int currentBucketIndex = 0;

    while (!done) {
      LinkedElement<T> current = entries[currentBucketIndex];
      while (current != null) {
        retList.add(current.element);
        current = current.next;
        entries[currentBucketIndex] = current;
        size--;
        modification++;
        if (--n == 0) {
          done = true;
          break;
        }
      }
      currentBucketIndex++;
    }
    shrinkIfNecessary();
    return retList;
  }
1344084
public List<T> first(final int n) {
        N.checkArgument(n >= 0, "'n' can't be negative: " + n);

        if (N.isNullOrEmpty(coll) || n == 0) {
            return new ArrayList<>();
        } else if (coll.size() <= n) {
            return new ArrayList<>(coll);
        } else if (coll instanceof List) {
            return new ArrayList<>(((List<T>) coll).subList(0, n));
        } else {
            final List<T> result = new ArrayList<>(N.min(n, coll.size()));
            int cnt = 0;

            for (T e : coll) {
                result.add(e);

                if (++cnt == n) {
                    break;
                }
            }

            return result;
        }
    }
682159
public Iterator breadthFirst() {
        return new Iterator() {
            private final List list = new LinkedList();
            private Iterator iter = iterator();
            private GPathResult next = getNextByBreadth();

            public boolean hasNext() {
                return this.next != null;
            }

            public Object next() {
                try {
                    return this.next;
                } finally {
                    this.next = getNextByBreadth();
                }
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }

            private GPathResult getNextByBreadth() {
                List children = new ArrayList();
                while (this.iter.hasNext() || !children.isEmpty()) {
                    if (this.iter.hasNext()) {
                        final GPathResult node = (GPathResult) this.iter.next();
                        this.list.add(node);
                        this.list.add(this.iter);
                        children.add(node.children());
                    } else {
                        List nextLevel = new ArrayList();
                        for (Object child : children) {
                            GPathResult next = (GPathResult) child;
                            Iterator iterator = next.iterator();
                            while (iterator.hasNext()) {
                                nextLevel.add(iterator.next());
                            }
                        }
                        this.iter = nextLevel.iterator();
                        children = new ArrayList();
                    }
                }
                if (this.list.isEmpty()) {
                    return null;
                } else {
                    GPathResult result = (GPathResult) this.list.get(0);
                    this.list.remove(0);
                    this.iter = (Iterator) this.list.get(0);
                    this.list.remove(0);
                    return result;
                }
            }
        };
    }
1203278
public E pollFirst() {
        final Node<E> f = first;
        return (f == null) ? null : unlinkFirst(f);
    }
1006869
private static <T> T firstOf(final List<T> list) {
        return list.isEmpty()? null: list.get(0);
    }
53772
public AbstractJournalOperation removeFirst()
    {
        AbstractJournalOperation op = head;
        if (op == null)
            throw new NoSuchElementException();
        
        head = op.next();
        if (head == null)
            tail = null;
        op.setNext(null);
        size--;
        
        return op;
    }
188869
public Iterator<E> iterator() {

        return new Iterator<E>() {

            public boolean hasNext() {
                return enumeration.hasMoreElements();
            }

            public E next() {
                return enumeration.nextElement();
            }

            public void remove() {
                throw new UnsupportedOperationException("IterableEnumeration does not support remove");
            }
        };
    }
369264
@Nullable
  public ResultT first() {
    final CoreRemoteMongoCursor<ResultT> cursor = iterator();
    if (!cursor.hasNext()) {
      return null;
    }
    return cursor.next();
  }
1196025
public Enumeration elements() {
		Iterator iter;
		Vector list;

		iter = m_Words.iterator();
		list = new Vector();

		while (iter.hasNext())
			list.add(iter.next());

		// sort list
		Collections.sort(list);

		return list.elements();
	}
285008
public static <E> E firstInList(List<E> list){
    	if (list == null || list.size() == 0){
    		return null;
    	}else{
    		return list.get(0);
    	}
    }
402106
function() {
                var nodes, i, node, self = this;
                // Remove all children
                if (self.firstChild) {
                    nodes = [];
                    // Collect the children
                    for (node = self.firstChild; node; node = walk(node, self)) {
                        nodes.push(node);
                    }
                    // Remove the children
                    i = nodes.length;
                    while (i--) {
                        node = nodes[i];
                        node.parent = node.firstChild = node.lastChild = node.next = node.prev = null;
                    }
                }
                self.firstChild = self.lastChild = null;
                return self;
            }
1143737
public LeftTupleSinkNode removeFirst() {
        if ( this.firstNode == null ) {
            return null;
        }
        final LeftTupleSinkNode node = this.firstNode;
        this.firstNode = node.getNextLeftTupleSinkNode();
        node.setNextLeftTupleSinkNode( null );
        if ( this.firstNode != null ) {
            this.firstNode.setPreviousLeftTupleSinkNode( null );
        } else {
            this.lastNode = null;
        }
        this.size--;
        return node;
    }
289154
public E removeLast() {
        final Node<E> l = last;
        if (l == null)
            throw new NoSuchElementException();
        return unlinkLast(l);
    }
296771
final Node firstDataNode() {
        restartFromHead: for (;;) {
            for (Node p = head; p != null;) {
                Object item = p.item;
                if (p.isData) {
                    if (item != null && item != FORGOTTEN)
                        return p;
                }
                else if (item == null)
                    break;
                if (UNLINKED == (p = p.next))
                    continue restartFromHead;
            }
            return null;
        }
    }
306525
protected Elements getFirst(Elements elems) {
        @SuppressWarnings("unchecked")
        IterableElements<Elements> iterableElems = elems.as(IterableElements.class);
        return Iterables.getFirst(iterableElems, null);
    }
491122
public E removeFirst() {
    E first = getFirst();
    swap(0, size - 1);
    size--;
    elements.remove(size);
    heapifyDown(0);
    return first;
  }
413817
@Override
    public Iterator<Object> iterator() {
        return new Iterator<Object>() {

            int currentPosition = 0;

            @Override
            public boolean hasNext() {
                return masterSequence.size() > currentPosition;
            }

            @Override
            public Object next() {
                if (currentPosition <= masterSequence.size())
                    return masterSequence.get(currentPosition++);
                return null;
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException("Remove is not supported.");

            }

        };
    }