Class EmptyStackView<T>

java.lang.Object
io.karma.sliced.view.impl.EmptyStackView<T>
All Implemented Interfaces:
StackView<T>, View<T>, Iterable<T>

@API(status=INTERNAL) public final class EmptyStackView<T> extends Object implements StackView<T>
Since:
25/02/2024
  • Field Details

  • Constructor Details

    • EmptyStackView

      public EmptyStackView()
  • Method Details

    • peek

      public T peek()
      Description copied from interface: StackView
      Retrieves the current, topmost element on the stack. Returns null if the stack is empty.
      Specified by:
      peek in interface StackView<T>
      Returns:
      The current topmost element on the stack. Null if the stack is empty.
    • size

      public int size()
      Description copied from interface: View
      Retrieves the number of elements contained within the array/collection referenced by this array.
      Specified by:
      size in interface View<T>
      Returns:
      The number of element contained within the collection/array referenced by this view instance.
    • asSlice

      @NotNull public @NotNull Slice<T> asSlice()
      Description copied from interface: View
      Creates a new slice instance from this view instance containing the same underlying collection reference, or a newly created wrapper list if there's no specialization available for the type of the underlying collection. Note If you want to create slices directly, see Slice.of(Object[]) and it's overloads.
      Specified by:
      asSlice in interface View<T>
      Returns:
      A new slice instance with a reference to the same collection/array as this view instance.
    • iterator

      @NotNull public @NotNull Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>