Class AbstractSectionedArrayCollection<E>

Type Parameters:
E - type of contained elements
All Implemented Interfaces:
ExtendedCollection<E>, Sized
Direct Known Subclasses:
AbstractSimpleArrayCollection

public abstract class AbstractSectionedArrayCollection<E>
extends AbstractArrayCollection<E>
  • Constructor Details

  • Method Details

    • internalGetStorageArray

      protected abstract E[] internalGetStorageArray()
      This is an internal shortcut method to provide fast access to the various array-backed collection implementations' storage arrays.
      The purpose of this method is to allow access to the array only for read-only procedures, never for modifying accesses.

      The returned array is expected to contain the elements of the list in an order defined by the sectionIndices provided by internalGetSectionIndices()

      Specified by:
      internalGetStorageArray in class AbstractArrayCollection<E>
      Returns:
      the storage array used by the list, containing all elements in sectioned order.
    • internalGetSectionIndices

      protected abstract int[] internalGetSectionIndices()
      Defines the array sections in which the collection's elements are organized by one or more pairs of indices in the order corresponding to the collection's logical order of its contained elements.

      Examples:
      The trivial example would be {0,size} in case of standard sized array collections.
      An example for actual sectioning would be {i,array.length - 1, 0,i - 1} in case of a ring buffer list comprised of two sections: one ranging from index i to array.length - 1 (with the oldest element located at i) and one ranging from 0 to i - 1 (with the newest element located at i - 1).

      Returns:
      a list of index pairs defining all sections of the storage array in logical order.