[url=][/url]
public E element() { return getFirst(); } public E getFirst() { E x = elements[head]; if (x == null) throw new NoSuchElementException(); return x; } public E peek() { return peekFirst(); } public E peekFirst() { return elements[head]; // elements[head] is null if deque empty } public E getLast() { E x = elements[(tail - 1) & (elements.length - 1)]; if (x == null) throw new NoSuchElementException(); return x; } public E peekLast() { return elements[(tail - 1) & (elements.length - 1)]; } [url=][/url]