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 ClassesModifier and TypeClassDescriptionstatic interfaceAn element contained in this list.classAn iterator over the intrusive collection. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd an element to the end of the list.booleanaddAll(Collection<? extends E> collection) booleanAdd an element to the front of the list.voidclear()Remove all elements.booleanbooleancontainsAll(Collection<?> collection) booleanisEmpty()iterator()Get an iterator over the list.booleanbooleanremoveAll(Collection<?> collection) booleanretainAll(Collection<?> collection) intsize()Object[]toArray()<T> T[]toArray(T[] array) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
IntrusiveCollection
public IntrusiveCollection()
-
-
Method Details
-
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:
iteratorin interfaceCollection<E extends IntrusiveCollection.Element>- Specified by:
iteratorin interfaceIterable<E extends IntrusiveCollection.Element>- Returns:
- The iterator.
-
size
public int size()- Specified by:
sizein interfaceCollection<E extends IntrusiveCollection.Element>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E extends IntrusiveCollection.Element>
-
contains
- Specified by:
containsin interfaceCollection<E extends IntrusiveCollection.Element>
-
toArray
- Specified by:
toArrayin interfaceCollection<E extends IntrusiveCollection.Element>
-
toArray
public <T> T[] toArray(T[] array) - Specified by:
toArrayin interfaceCollection<E extends IntrusiveCollection.Element>
-
add
Add an element to the end of the list.- Specified by:
addin interfaceCollection<E extends IntrusiveCollection.Element>- Parameters:
elem- The new element to add.- Returns:
- add result.
-
addFirst
Add an element to the front of the list.- Parameters:
elem- The new element to add.- Returns:
- if addFirst success true, not false.
-
remove
- Specified by:
removein interfaceCollection<E extends IntrusiveCollection.Element>
-
containsAll
- Specified by:
containsAllin interfaceCollection<E extends IntrusiveCollection.Element>
-
addAll
- Specified by:
addAllin interfaceCollection<E extends IntrusiveCollection.Element>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E extends IntrusiveCollection.Element>
-
retainAll
- Specified by:
retainAllin interfaceCollection<E extends IntrusiveCollection.Element>
-
clear
public void clear()Remove all elements.- Specified by:
clearin interfaceCollection<E extends IntrusiveCollection.Element>
-