Class StackUtils

java.lang.Object
panda.utilities.StackUtils

public final class StackUtils extends Object
  • Method Details

    • push

      @SafeVarargs public static <T> Stack<T> push(Stack<T> stack, T... values)
      Push multiple values at once
      Type Parameters:
      T - the type of the stack content
      Parameters:
      stack - the stack to fill
      values - the values to push
      Returns:
      the stack
    • popSilently

      public static <T> Stack<T> popSilently(Stack<T> stack, int amount)
      Pop multiple values at once without worries that the stack is empty
      Type Parameters:
      T - the type of the values
      Parameters:
      stack - the stack to drain
      amount - amount of values to pop
      Returns:
      the stack
    • fill

      public static <T> Stack<T> fill(Stack<T> stack, T object, int amount)
      Fill the stack with the specified object
      Type Parameters:
      T - the type of the values
      Parameters:
      stack - the stack to fill
      object - the object to push
      amount - amount of pushes
      Returns:
      the stack
    • reverse

      public static <T> Stack<T> reverse(Stack<T> stack)
      Reverse the stack
      Type Parameters:
      T - the type of the values
      Parameters:
      stack - the stack to reverse
      Returns:
      the stack with reversed values (the same instance)
    • of

      public static <T> Stack<T> of(Collection<? extends T> collection)
      Create stack using another collection
      Type Parameters:
      T - type of collection
      Parameters:
      collection - the collection to use
      Returns:
      a new stack based on the specified collection