com.holonplatform.core.utils

## Class SizedStack<T>

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - java.util.AbstractList<E>
    - - java.util.Vector<E>
      - - java.util.Stack<T>
        - - com.holonplatform.core.utils.SizedStack<T>

- Type Parameters:
    `T` - Stack elements type
  All Implemented Interfaces:
    Serializable, Cloneable, Iterable<T>, Collection<T>, List<T>, RandomAccess

      public class SizedStack<T>
      extends Stack<T>

  `Stack` extension which supports a max stack size.

  If max size is valid (`>0`), when stack size exceeds max size, the eldest element is removed before adding a new one on the top of the stack.

  Since:
    5.0.0
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SizedStack(int maxSize)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getMaxSize()` Stack max size
    `T` | `push(T item)`

    - ### Methods inherited from class java.util.Stack

      `empty, peek, pop, search`

    - ### Methods inherited from class java.util.Vector

      `add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, forEach, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeIf, replaceAll, retainAll, set, setElementAt, setSize, size, sort, spliterator, subList, toArray, toArray, toString, trimToSize`

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

      `getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Collection

      `parallelStream, stream`

- - ### Constructor Detail

    - #### SizedStack

          public SizedStack(int maxSize)

      Constructor
      Parameters:
        `maxSize` - Max stack size. If `$lt;=0`, max size is ignored and a standard unbound stack is created.

  - ### Method Detail

    - #### getMaxSize

          public int getMaxSize()

      Stack max size
      Returns:
        the max size

    - #### push

          public T push(T item)

      Overrides:
        `push` in class `Stack<T>`

Copyright © 2017 The Holon Platform. All rights reserved.