Class PSquarePercentile.FixedCapacityList<E>

  • Type Parameters:
    E -
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess
    Enclosing class:
    PSquarePercentile

    private static class PSquarePercentile.FixedCapacityList<E>
    extends java.util.ArrayList<E>
    implements java.io.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 Summary

      Fields 
      Modifier and Type Field Description
      private int capacity
      Capacity of the list
      private static long serialVersionUID
      Serialization Version Id
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      FixedCapacityList​(int fixedCapacity)
      This constructor constructs the list with given capacity and as well as stores the capacity
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      boolean addAll​(java.util.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.
      • Methods inherited from class java.util.ArrayList

        add, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
      • Methods inherited from class java.util.AbstractList

        equals, hashCode
      • Methods inherited from class java.util.AbstractCollection

        containsAll, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream
      • Methods inherited from interface java.util.List

        containsAll, equals, hashCode
    • Field Detail

      • serialVersionUID

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

        private final int capacity
        Capacity of the list
    • Constructor Detail

      • 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 Detail

      • 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 java.util.Collection<E>
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class java.util.ArrayList<E>
        Returns:
        true if addition is successful and false otherwise
      • addAll

        public boolean addAll​(java.util.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 java.util.Collection<E>
        Specified by:
        addAll in interface java.util.List<E>
        Overrides:
        addAll in class java.util.ArrayList<E>
        Returns:
        true if addition is successful and false otherwise