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

Package org.apache.hadoop.util

# Class IntrusiveCollection<E extends IntrusiveCollection.Element>

java.lang.Object
org.apache.hadoop.util.IntrusiveCollection<E>

All Implemented Interfaces:
  `Iterable<E>`, `Collection<E>`

@Private public class IntrusiveCollection<E extends IntrusiveCollection.Element> extends Object implements Collection<E>
Implements an intrusive doubly-linked list. An intrusive linked list is one in which the elements themselves are responsible for storing the pointers to previous and next elements. This can save a lot of memory if there are many elements in the list or many lists.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `IntrusiveCollection.Element`
  An element contained in this list.
  `class`
  `IntrusiveCollection.IntrusiveIterator`
  An iterator over the intrusive collection.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final org.slf4j.Logger`
  `LOG`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `IntrusiveCollection()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `add(E elem)`
  Add an element to the end of the list.
  `boolean`
  `addAll(Collection<? extends E> collection)`
  `boolean`
  `addFirst(IntrusiveCollection.Element elem)`
  Add an element to the front of the list.
  `void`
  `clear()`
  Remove all elements.
  `boolean`
  `contains(Object o)`
  `boolean`
  `containsAll(Collection<?> collection)`
  `boolean`
  `isEmpty()`
  `Iterator<E>`
  `iterator()`
  Get an iterator over the list.
  `boolean`
  `remove(Object o)`
  `boolean`
  `removeAll(Collection<?> collection)`
  `boolean`
  `retainAll(Collection<?> collection)`
  `int`
  `size()`
  `Object[]`
  `toArray()`
  `<T> T[]`
  `toArray(T[] array)`

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

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

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

  `equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray`

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

  `forEach`

- ## Field Details

  - ### LOG

    public static final org.slf4j.Logger LOG

- ## Constructor Details

  - ### IntrusiveCollection

    public IntrusiveCollection()

- ## Method Details

  - ### iterator

    public Iterator<E> iterator()
    Get an iterator over the list. This can be used to remove elements. It is not safe to do concurrent modifications from other threads while using this iterator.
    Specified by:
      `iterator` in interface `Collection<E extends IntrusiveCollection.Element>`
    Specified by:
      `iterator` in interface `Iterable<E extends IntrusiveCollection.Element>`
    Returns:
      The iterator.

  - ### size

    public int size()
    Specified by:
      `size` in interface `Collection<E extends IntrusiveCollection.Element>`

  - ### isEmpty

    public boolean isEmpty()
    Specified by:
      `isEmpty` in interface `Collection<E extends IntrusiveCollection.Element>`

  - ### contains

    public boolean contains(Object o)
    Specified by:
      `contains` in interface `Collection<E extends IntrusiveCollection.Element>`

  - ### toArray

    public Object[] toArray()
    Specified by:
      `toArray` in interface `Collection<E extends IntrusiveCollection.Element>`

  - ### toArray

    public <T> T[] toArray(T[] array)
    Specified by:
      `toArray` in interface `Collection<E extends IntrusiveCollection.Element>`

  - ### add

    public boolean add(E elem)
    Add an element to the end of the list.
    Specified by:
      `add` in interface `Collection<E extends IntrusiveCollection.Element>`
    Parameters:
      `elem` - The new element to add.
    Returns:
      add result.

  - ### addFirst

    public boolean addFirst(IntrusiveCollection.Element elem)
    Add an element to the front of the list.
    Parameters:
      `elem` - The new element to add.
    Returns:
      if addFirst success true, not false.

  - ### remove

    public boolean remove(Object o)
    Specified by:
      `remove` in interface `Collection<E extends IntrusiveCollection.Element>`

  - ### containsAll

    public boolean containsAll(Collection<?> collection)
    Specified by:
      `containsAll` in interface `Collection<E extends IntrusiveCollection.Element>`

  - ### addAll

    public boolean addAll(Collection<? extends E> collection)
    Specified by:
      `addAll` in interface `Collection<E extends IntrusiveCollection.Element>`

  - ### removeAll

    public boolean removeAll(Collection<?> collection)
    Specified by:
      `removeAll` in interface `Collection<E extends IntrusiveCollection.Element>`

  - ### retainAll

    public boolean retainAll(Collection<?> collection)
    Specified by:
      `retainAll` in interface `Collection<E extends IntrusiveCollection.Element>`

  - ### clear

    public void clear()
    Remove all elements.
    Specified by:
      `clear` in interface `Collection<E extends IntrusiveCollection.Element>`