Package io.opentelemetry.sdk.internal
Class DynamicPrimitiveLongList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<java.lang.Long>
-
- io.opentelemetry.sdk.internal.DynamicPrimitiveLongList
-
- All Implemented Interfaces:
java.lang.Iterable<java.lang.Long>,java.util.Collection<java.lang.Long>,java.util.List<java.lang.Long>
public class DynamicPrimitiveLongList extends java.util.AbstractList<java.lang.Long>A resizable list for storing primitive `long` values.This class implements a dynamically resizable list specifically for primitive long values. The values are stored in a chain of arrays (named sub-array), so it can grow efficiently, by adding more sub-arrays per its defined size. The backing array also helps avoid auto-boxing and helps provide access to values as primitives without boxing.
The list is designed to minimize memory allocations, by:
- Adding sub-arrays and not creating new arrays and copying.
- When the size is changing to a smaller size, arrays are not removed.
Supported
List<Long>methods:get(int)- Retrieves the element at the specified position in this list as aLongobject.set(int, Long)- Replaces the element at the specified position in this list with the specifiedLongobject.size()- Returns the number of elements in this list.
Additional utility methods:
getLong(int)- Retrieves the element at the specified position in this list as a primitive long.setLong(int, long)- Replaces the element at the specified position in this list with the specified primitive long element.resizeAndClear(int)- Resizes the list to the specified size, resetting all elements to zero.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
This class is not thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description private intarrayCountprivate long[][]arraysprivate static intDEFAULT_SUBARRAY_CAPACITYprivate intsizeprivate intsubarrayCapacity
-
Constructor Summary
Constructors Constructor Description DynamicPrimitiveLongList()DynamicPrimitiveLongList(int subarrayCapacity)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DynamicPrimitiveLongListempty()private voidensureCapacity(int minCapacity)java.lang.Longget(int index)longgetLong(int index)static DynamicPrimitiveLongListof(long... values)static DynamicPrimitiveLongListofSubArrayCapacity(int subarrayCapacity)private java.lang.StringoutOfBoundsMsg(int index)private voidrangeCheck(int index)voidresizeAndClear(int newSize)java.lang.Longset(int index, java.lang.Long element)longsetLong(int index, long element)intsize()-
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
-
-
-
Field Detail
-
DEFAULT_SUBARRAY_CAPACITY
private static final int DEFAULT_SUBARRAY_CAPACITY
- See Also:
- Constant Field Values
-
subarrayCapacity
private final int subarrayCapacity
-
arrays
private long[][] arrays
-
size
private int size
-
arrayCount
private int arrayCount
-
-
Method Detail
-
of
public static DynamicPrimitiveLongList of(long... values)
-
ofSubArrayCapacity
public static DynamicPrimitiveLongList ofSubArrayCapacity(int subarrayCapacity)
-
empty
public static DynamicPrimitiveLongList empty()
-
get
public java.lang.Long get(int index)
- Specified by:
getin interfacejava.util.List<java.lang.Long>- Specified by:
getin classjava.util.AbstractList<java.lang.Long>
-
getLong
public long getLong(int index)
-
set
public java.lang.Long set(int index, java.lang.Long element)- Specified by:
setin interfacejava.util.List<java.lang.Long>- Overrides:
setin classjava.util.AbstractList<java.lang.Long>
-
setLong
public long setLong(int index, long element)
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection<java.lang.Long>- Specified by:
sizein interfacejava.util.List<java.lang.Long>- Specified by:
sizein classjava.util.AbstractCollection<java.lang.Long>
-
resizeAndClear
public void resizeAndClear(int newSize)
-
ensureCapacity
private void ensureCapacity(int minCapacity)
-
rangeCheck
private void rangeCheck(int index)
-
outOfBoundsMsg
private java.lang.String outOfBoundsMsg(int index)
-
-