de.caff.generics

## Class CopierFStackImpl<T>

- java.lang.Object
- - de.caff.generics.CopierFStackImpl<T>

- Type Parameters:
    `T` - element type
  All Implemented Interfaces:
    FStack<T>, java.lang.Iterable<T>

      class CopierFStackImpl<T>
      extends java.lang.Object
      implements FStack<T>

  Implementation of a functional stack which takes care of mutable elements by copying them.

  See `FStack` for more information.

  Since:
    September 22, 2020
  Author:
    Rammi

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) static class` | `CopierFStackImpl.Empty<T>` Empty copier stack implementation.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CopierFStackImpl(Copier<T> copier, T element, FStack<T> tail)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isEmpty()` Is this stack empty?
    `FStack<T>` | `pop()` Pop the stack.
    `FStack<T>` | `push(T elem)` Push an element to the top of the stack.
    `int` | `size()` Get the size of this stack.
    `T` | `top()` Get the top element of the stack.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface de.caff.generics.FStack

      `empty, empty, emptyCopyable, from, from, fromCopyable, iterator, pushAll, reverseFrom, reverseFrom, reverseFromCopyable, reversePushAll`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Constructor Detail

    - #### CopierFStackImpl

          CopierFStackImpl(@NotNull
                           Copier<T> copier,
                           T element,
                           @NotNull
                           FStack<T> tail)

      Constructor.
      Parameters:
        `copier` - copier use on incoming and outgoing elements
        `element` - element at the top of this stack
        `tail` - tails elements of this stack

  - ### Method Detail

    - #### top

          public T top()

      Description copied from interface: `FStack`
      Get the top element of the stack.
      Specified by:
        `top` in interface `FStack<T>`
      Returns:
        top element

    - #### push

          @NotNull
          public FStack<T> push(T elem)

      Description copied from interface: `FStack`
      Push an element to the top of the stack. This will not change this stack but return a new stack with the given element at the `FStack.top()`.
      Specified by:
        `push` in interface `FStack<T>`
      Parameters:
        `elem` - element to push to the stack
      Returns:
        new stack with `elem` at the top and the same elements as this stack below it

    - #### pop

          @NotNull
          public FStack<T> pop()

      Description copied from interface: `FStack`
      Pop the stack. This will remove the top-most element from the stack and return a new stack without it.
      Specified by:
        `pop` in interface `FStack<T>`
      Returns:
        a new stack without the top element of this stack

    - #### isEmpty

          public boolean isEmpty()

      Description copied from interface: `FStack`
      Is this stack empty? An empty stack does not have a top element, therefore `FStack.top()` and `FStack.pop()` are not allowed and will result in `EmptyStackException`s
      Specified by:
        `isEmpty` in interface `FStack<T>`
      Returns:

    - #### size

          public int size()

      Description copied from interface: `FStack`
      Get the size of this stack. This is an expensive operation!
      Specified by:
        `size` in interface `FStack<T>`
      Returns:
        number of elements in this stack