Class PSquarePercentile.FixedCapacityList<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<E>
org.apache.commons.math3.stat.descriptive.rank.PSquarePercentile.FixedCapacityList<E>
Type Parameters:
E -
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess
Enclosing class:
PSquarePercentile

private static class PSquarePercentile.FixedCapacityList<E> extends ArrayList<E> implements Serializable
A simple fixed capacity list that has an upper bound to growth. Once its capacity is reached, add is a no-op, returning false.
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization Version Id
      See Also:
    • capacity

      private final int capacity
      Capacity of the list
  • Constructor Details

    • FixedCapacityList

      FixedCapacityList(int fixedCapacity)
      This constructor constructs the list with given capacity and as well as stores the capacity
      Parameters:
      fixedCapacity - the capacity to be fixed for this list
  • Method Details

    • add

      public boolean add(E e)
      In addition it checks if the ArrayList.size() returns a size that is within capacity and if true it adds; otherwise the list contents are unchanged and false is returned.
      Specified by:
      add in interface Collection<E>
      Specified by:
      add in interface List<E>
      Overrides:
      add in class ArrayList<E>
      Returns:
      true if addition is successful and false otherwise
    • addAll

      public boolean addAll(Collection<? extends E> collection)
      In addition it checks if the sum of Collection size and this instance's ArrayList.size() returns a value that is within capacity and if true it adds the collection; otherwise the list contents are unchanged and false is returned.
      Specified by:
      addAll in interface Collection<E>
      Specified by:
      addAll in interface List<E>
      Overrides:
      addAll in class ArrayList<E>
      Returns:
      true if addition is successful and false otherwise