ChunkedArrayList (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util, class: ChunkedArrayList

Package org.apache.hadoop.util

# Class ChunkedArrayList<T>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<T>
org.apache.hadoop.util.ChunkedArrayList<T>

All Implemented Interfaces:
  `Iterable<T>`, `Collection<T>`, `List<T>`

@Private public class ChunkedArrayList<T> extends AbstractList<T>
Simplified List implementation which stores elements as a list of chunks, each chunk having a maximum size. This improves over using an ArrayList in that creating a large list will never require a large amount of contiguous heap space -- thus reducing the likelihood of triggering a CMS compaction pause due to heap fragmentation. The first chunks allocated are small, but each additional chunk is 50% larger than the previous, ramping up to a configurable maximum chunk size. Reasonable defaults are provided which should be a good balance between not making any large allocations while still retaining decent performance. This currently only supports a small subset of List operations -- namely addition and iteration.

- ## Field Summary

  ### Fields inherited from class java.util.AbstractList

  `modCount`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ChunkedArrayList()`
  `ChunkedArrayList(int initialChunkCapacity, int maxChunkSize)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `add(T e)`
  `void`
  `clear()`
  `T`
  `get(int idx)`
  `boolean`
  `isEmpty()`
  `Iterator<T>`
  `iterator()`
  `int`
  `size()`

  ### Methods inherited from class java.util.AbstractList

  `add, addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList`

  ### Methods inherited from class java.util.AbstractCollection

  `addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString`

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

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

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

  `parallelStream, removeIf, stream, toArray`

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

  `forEach`

  ### Methods inherited from interface java.util.List

  `addAll, contains, containsAll, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray`

- ## Constructor Details

  - ### ChunkedArrayList

    public ChunkedArrayList()

  - ### ChunkedArrayList

    public ChunkedArrayList(int initialChunkCapacity, int maxChunkSize)
    Parameters:
      `initialChunkCapacity` - the capacity of the first chunk to be allocated
      `maxChunkSize` - the maximum size of any chunk allocated

- ## Method Details

  - ### iterator

    public Iterator<T> iterator()
    Specified by:
      `iterator` in interface `Collection<T>`
    Specified by:
      `iterator` in interface `Iterable<T>`
    Specified by:
      `iterator` in interface `List<T>`
    Overrides:
      `iterator` in class `AbstractList<T>`

  - ### add

    public boolean add(T e)
    Specified by:
      `add` in interface `Collection<T>`
    Specified by:
      `add` in interface `List<T>`
    Overrides:
      `add` in class `AbstractList<T>`

  - ### clear

    public void clear()
    Specified by:
      `clear` in interface `Collection<T>`
    Specified by:
      `clear` in interface `List<T>`
    Overrides:
      `clear` in class `AbstractList<T>`

  - ### isEmpty

    public boolean isEmpty()
    Specified by:
      `isEmpty` in interface `Collection<T>`
    Specified by:
      `isEmpty` in interface `List<T>`
    Overrides:
      `isEmpty` in class `AbstractCollection<T>`

  - ### size

    public int size()
    Specified by:
      `size` in interface `Collection<T>`
    Specified by:
      `size` in interface `List<T>`
    Specified by:
      `size` in class `AbstractCollection<T>`

  - ### get

    public T get(int idx)
    Specified by:
      `get` in interface `List<T>`
    Specified by:
      `get` in class `AbstractList<T>`