Class LinkedArrayList
java.lang.Object
io.reactivex.rxjava3.internal.util.LinkedArrayList
A list implementation which combines an ArrayList with a LinkedList to
avoid copying values when the capacity needs to be increased.
The class is non final to allow embedding it directly and thus saving on object allocation.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final int
The capacity of each array segment.(package private) Object[]
Contains the head of the linked array list if not null.(package private) int
The next available slot in the current tail.(package private) int
The total size of the list; written after elements have been added (release) and and when read, the value indicates how many elements can be safely read (acquire).(package private) Object[]
The tail array where new elements will be added. -
Constructor Summary
ConstructorsConstructorDescriptionLinkedArrayList
(int capacityHint) Constructor with the capacity hint of each array segment. -
Method Summary
-
Field Details
-
capacityHint
final int capacityHintThe capacity of each array segment. -
head
Object[] headContains the head of the linked array list if not null. The length is always capacityHint + 1 and the last element is an Object[] pointing to the next element of the linked array list. -
tail
Object[] tailThe tail array where new elements will be added. -
size
volatile int sizeThe total size of the list; written after elements have been added (release) and and when read, the value indicates how many elements can be safely read (acquire). -
indexInTail
int indexInTailThe next available slot in the current tail.
-
-
Constructor Details
-
LinkedArrayList
public LinkedArrayList(int capacityHint) Constructor with the capacity hint of each array segment.- Parameters:
capacityHint
- the expected number of elements to hold (can grow beyond that)
-
-
Method Details
-
add
Adds a new element to this list.- Parameters:
o
- the object to add, nulls are accepted
-
head
Returns the head buffer segment or null if the list is empty.- Returns:
- the head object array
-
size
public int size()Returns the total size of the list.- Returns:
- the total size of the list
-
toString
-