Return the head of the queue without modifying the queue.

@return the data at the head of the queue.
@throws Exception errors
@throws NoSuchElementException if the queue is empty
323124
public byte[] element() throws Exception
    {
        byte[] bytes = internalElement(false, null);
        if ( bytes == null )
        {
            throw new NoSuchElementException();
        }
        return bytes;
    }
255748
public String next() {
	if (next == null) {
	    throw new NoSuchElementException();
	}
	String s = next;
	advance();
	return s;
    }
276087
@Override
  public void printHeads(final Parse parse) {
    if (parse == null || parse.getChildCount() == 0) {
      throw new IllegalArgumentException(
          "Can't return head of null or leaf Parse.");
    }
    final LinkedList<Parse> nodes = new LinkedList<Parse>();
    nodes.add(parse);
    // This is a recursive iteration over the whole parse tree
    while (!nodes.isEmpty()) {
      final Parse currentNode = nodes.removeFirst();
      // When a node is here its '=H' annotation has already happened
      // so it '=H' has to be removed to match with the head rules
      final String type = currentNode.getType().replace(HEADMARK, "");
      if (DEBUG) {
        System.err
            .println("-> Current Node: " + type + " " + currentNode.toString());
      }
      final Parse[] children = currentNode.getChildren();
      Parse headChild = null;
      if (children.length > 0) {
        headChild = this.headRules.getHead(children, type);
      }
      // For every child, if it is the head, annotate with '=H'
      // and also add to the queue for the recursive processing
      for (final Parse child : currentNode.getChildren()) {
        if (child == headChild) {
          child.setType(child.getType() + HEADMARK);
        }
        // add child to last of LinkedList which will
        // now take as currentNode the child of this child
        nodes.addLast(child);
      }
    }
  }
1063177
public function rear() {
        if (null === $this->queue) return null;
        if (!isset($this->queue[$this->head])) return null;
        return $this->queue[$this->head];
    }
334940
public T read () {
		if (size > 0) {
			size--;
			T item = items[head];
			items[head] = null; // Avoid keeping useless references
			if (++head == items.length) head = 0;
			return item;
		}

		return null;
	}
347484
public AbstractQueue<ID, DATA> init() throws Exception {
        if (observer != null) {
            observer.preInit(this);
        }
        try {
            return this;
        } finally {
            if (observer != null) {
                observer.postInit(this);
            }
        }
    }
147634
protected function getQueue()
        {
            if (null === $this->queue) {
                $this->queue = new $this->queueClass();

                if (!$this->queue instanceof SplPriorityQueue) {
                    throw new Exception(sprintf(
                        'Queue expects an internal queue of type SplPriorityQueue; received "%s"',
                        get_class($this->queue)
                    ));
                }
            }

            return $this->queue;
        }
422756
public function get_grouping_head()
    {
        if (!$this->is_single_grouping())
            throw new \Exception('Cannot use ' . __METHOD__ . ' here');
        foreach ($this->get_elements() as $record) {
            return $record;
        }
    }
518347
@Override
    public E last()
    {
        if (list.isEmpty())
        {
            throw new NoSuchElementException();
        }
        return list.get(list.size()-1);
    }
588339
public function getHeader()
    {
        if (null == $this->header) {
            $header = $this->getNextDataSet();
            if (null === $header) {
                throw new Exception("Cannot retrieve header");
            }
            $this->setHeader($header);
        }

        return $this->header;
    }
481753
public synchronized T next() {
	if (current == null) {
	    throw new NoSuchElementException();
	}
	T t = current.next();
        // Once an element has been drawn from the iterator, the current
        // iterator should be used for any subsequent remove call.
        if (toRemoveFrom != current)
            toRemoveFrom = current;
	advance();
	return t;
    }
463437
public int deQueue()
    {
        if ( size == 0 ) {
            return -1;
        }
        
        //remove the first element
        Entry o = head.next;
        head.next = o.next;
        o.next.prev = head;
        
        //backup the data
        int v = o.data;
        size--;
        o = null;        //Let gc do its work
        
        return v;
    }
73404
public Head getHead() {
    if (EntityMention_Type.featOkTst && ((EntityMention_Type)jcasType).casFeat_head == null)
      jcasType.jcas.throwFeatMissing("head", "de.julielab.jules.types.ace.EntityMention");
    return (Head)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((EntityMention_Type)jcasType).casFeatCode_head)));}
136884
private Node<E> extract() {
		Node<E> current = head;
		head = head.next;

		current.item = head.item;
		head.item = null;

		return current;
	}
998447
def head(self):
        
        if self._head is None:
            self._head = self.sentence.tokens[self._head_id-1]
        return self._head
1314087
synchronized public E get() {
		if (this.isClosed())
			throw new NoSuchElementException();

		while (this.elements.isEmpty()) {
			try {
				this.wait();
			} catch (final InterruptedException e) {
				Thread.currentThread().interrupt();
				throw new RuntimeException(e);
			}
		}
		return this.elements.remove();
	}
311312
public Entry<T> dequeueMin() {
        /* Check for whether we're empty. */
        if (isEmpty())
            throw new NoSuchElementException("Heap is empty.");

        /* Otherwise, we're about to lose an element, so decrement the number of
         * entries in this heap.
         */
        --mSize;

        /* Grab the minimum element so we know what to return. */
        Entry<T> minElem = mMin;

        /* Now, we need to get rid of this element from the list of roots.  There
         * are two cases to consider.  First, if this is the only element in the
         * list of roots, we set the list of roots to be null by clearing mMin.
         * Otherwise, if it's not null, then we write the elements next to the
         * min element around the min element to remove it, then arbitrarily
         * reassign the min.
         */
        if (mMin.mNext == mMin) { // Case one
            mMin = null;
        } else { // Case two
            mMin.mPrev.mNext = mMin.mNext;
            mMin.mNext.mPrev = mMin.mPrev;
            mMin = mMin.mNext; // Arbitrary element of the root list.
        }

        /* Next, clear the parent fields of all of the min element's children,
         * since they're about to become roots.  Because the elements are
         * stored in a circular list, the traversal is a bit complex.
         */
        if (minElem.mChild != null) {
            /* Keep track of the first visited node. */
            Entry<?> curr = minElem.mChild;
            do {
                curr.mParent = null;

                /* Walk to the next node, then stop if this is the node we
                 * started at.
                 */
                curr = curr.mNext;
            } while (curr != minElem.mChild);
        }

        /* Next, splice the children of the root node into the topmost list,
         * then set mMin to point somewhere in that list.
         */
        mMin = mergeLists(mMin, minElem.mChild);

        /* If there are no entries left, we're done. */
        if (mMin == null) return minElem;

        /* Next, we need to coalsce all of the roots so that there is only one
         * tree of each degree.  To track trees of each size, we allocate an
         * ArrayList where the entry at position i is either null or the
         * unique tree of degree i.
         */
        List<Entry<T>> treeTable = new ArrayList<Entry<T>>();

        /* We need to traverse the entire list, but since we're going to be
         * messing around with it we have to be careful not to break our
         * traversal order mid-stream.  One major challenge is how to detect
         * whether we're visiting the same node twice.  To do this, we'll
         * spent a bit of overhead adding all of the nodes to a list, and
         * then will visit each element of this list in order.
         */
        List<Entry<T>> toVisit = new ArrayList<Entry<T>>();

        /* To add everything, we'll iterate across the elements until we
         * find the first element twice.  We check this by looping while the
         * list is empty or while the current element isn't the first element
         * of that list.
         */
        for (Entry<T> curr = mMin; toVisit.isEmpty() || toVisit.get(0) != curr; curr = curr.mNext)
            toVisit.add(curr);

        /* Traverse this list and perform the appropriate unioning steps. */
        for (Entry<T> curr : toVisit) {
            /* Keep merging until a match arises. */
            while (true) {
                /* Ensure that the list is long enough to hold an element of this
                 * degree.
                 */
                while (curr.mDegree >= treeTable.size())
                    treeTable.add(null);

                /* If nothing's here, we're can record that this tree has this size
                 * and are done processing.
                 */
                if (treeTable.get(curr.mDegree) == null) {
                    treeTable.set(curr.mDegree, curr);
                    break;
                }

                /* Otherwise, merge with what's there. */
                Entry<T> other = treeTable.get(curr.mDegree);
                treeTable.set(curr.mDegree, null); // Clear the slot

                /* Determine which of the two trees has the smaller root, storing
                 * the two tree accordingly.
                 */
                Entry<T> min = (other.mPriority < curr.mPriority) ? other : curr;
                Entry<T> max = (other.mPriority < curr.mPriority) ? curr : other;

                /* Break max out of the root list, then merge it into min's child
                 * list.
                 */
                max.mNext.mPrev = max.mPrev;
                max.mPrev.mNext = max.mNext;

                /* Make it a singleton so that we can merge it. */
                max.mNext = max.mPrev = max;
                min.mChild = mergeLists(min.mChild, max);

                /* Reparent max appropriately. */
                max.mParent = min;

                /* Clear max's mark, since it can now lose another child. */
                max.mIsMarked = false;

                /* Increase min's degree; it now has another child. */
                ++min.mDegree;

                /* Continue merging this tree. */
                curr = min;
            }

            /* Update the global min based on this node.  Note that we compare
             * for <= instead of < here.  That's because if we just did a
             * reparent operation that merged two different trees of equal
             * priority, we need to make sure that the min pointer points to
             * the root-level one.
             */
            if (curr.mPriority <= mMin.mPriority) mMin = curr;
        }
        return minElem;
    }