/** * @see java.util.ArrayList#indexOf(java.lang.Object) */ @Override public int indexOf(Object elem) { int size = size(); if (elem == null) { for (int i = 0; i < size; i++) { if (get(i) == null) { return i; } } } else { for (int i = 0; i < size; i++) { if (elem == get(i)) { return i; } } } return -1; }
/** * Looks at the object at the top of this stack without removing it. * * @return The object at the top of this stack * @exception EmptyStackException * If this stack is empty. */ public final Object peek() { int size = size(); if (size == 0) { throw new EmptyStackException(); } return get(size - 1); }
/** * Looks at the object at the top of this stack without removing it. * * @return The object at the top of this stack * @exception EmptyStackException * If this stack is empty. */ public final T peek() { int size = size(); if (size == 0) { throw new EmptyStackException(); } return get(size - 1); }
/** * @see java.util.ArrayList#lastIndexOf(java.lang.Object) */ @Override public int lastIndexOf(Object elem) { if (elem == null) { for (int i = size() - 1; i >= 0; i--) { if (get(i) == null) { return i; } } } else { for (int i = size() - 1; i >= 0; i--) { if (elem == get(i)) { return i; } } } return -1; }