{@link #size()} - 1
element.
*/
@SuppressWarnings("unchecked")
@com.carrotsearch.hppc.Generated(date = "2024-06-04T15:20:17+0200", value = "KTypeStack.java")
public class ObjectStackThis method is handy, but costly if used in tight loops (anonymous array passing)
*/
@SafeVarargs
public final void push(KType... elements) {
push(elements, 0, elements.length);
}
/** Pushes all elements from another container to the top of the stack. */
public int pushAll(ObjectContainer extends KType> container) {
return addAll(container);
}
/** Pushes all elements from another iterable to the top of the stack. */
public int pushAll(Iterable extends ObjectCursor extends KType>> iterable) {
return addAll(iterable);
}
/** Discard an arbitrary number of elements from the top of the stack. */
public void discard(int count) {
assert elementsCount >= count;
elementsCount -= count;
Arrays.fill(buffer, elementsCount, elementsCount + count, null);
}
/** Discard the top element from the stack. */
public void discard() {
assert elementsCount > 0;
elementsCount--;
buffer[elementsCount] = null;
}
/** Remove the top element from the stack and return it. */
public KType pop() {
return removeLast();
}
/** Peek at the top element on the stack. */
public KType peek() {
assert elementsCount > 0;
return (KType) buffer[elementsCount - 1];
}
/** Create a stack by pushing a variable number of arguments to it. */
@SafeVarargs
public static