public static class SpinedBuffer.OfLong extends SpinedBuffer.OfPrimitive<Long,long[],LongConsumer> implements LongConsumer
long
values.Modifier and Type | Field and Description |
---|---|
protected int |
elementIndex
Index of the *next* element to write; may point into, or just outside of,
the current chunk.
|
protected int |
initialChunkPower
log2 of the size of the first chunk.
|
static int |
MAX_CHUNK_POWER
Max power-of-two for chunks.
|
static int |
MIN_CHUNK_POWER
Minimum power-of-two for the first chunk.
|
static int |
MIN_CHUNK_SIZE
Minimum size for the first chunk.
|
static int |
MIN_SPINE_SIZE
Minimum array size for array-of-chunks.
|
protected long[] |
priorElementCount
Count of elements in all prior chunks.
|
protected int |
spineIndex
Index of the *current* chunk in the spine array, if the spine array is
non-null.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(long i)
Performs this operation on the given argument.
|
protected void |
arrayForEach(long[] array,
int from,
int to,
LongConsumer consumer)
Iterate an array with the provided consumer
|
protected int |
arrayLength(long[] array)
Get the length of an array
|
protected int |
chunkSize(int n)
How big should the nth chunk be?
|
long |
count()
How many elements are currently in the buffer?
|
void |
forEach(Consumer<? super Long> consumer)
Performs the given action for each element of the
Iterable
until all elements have been processed or the action throws an
exception. |
long |
get(long index) |
boolean |
isEmpty()
Is the buffer currently empty?
|
PrimitiveIterator.OfLong |
iterator()
Returns an iterator over elements of type
T . |
long[] |
newArray(int size)
Create a new array of the proper type and size
|
protected long[][] |
newArrayArray(int size)
Create a new array-of-array of the proper type and size
|
Spliterator.OfLong |
spliterator()
Creates a
Spliterator over the elements described by this
Iterable . |
String |
toString()
Returns a string representation of the object.
|
asPrimitiveArray, capacity, chunkFor, clear, copyInto, ensureCapacity, forEach, increaseCapacity, preAccept
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
andThen
public static final int MIN_CHUNK_POWER
public static final int MIN_CHUNK_SIZE
public static final int MAX_CHUNK_POWER
public static final int MIN_SPINE_SIZE
protected final int initialChunkPower
protected int elementIndex
protected int spineIndex
protected long[] priorElementCount
public void forEach(Consumer<? super Long> consumer)
Iterable
Iterable
until all elements have been processed or the action throws an
exception. Unless otherwise specified by the implementing class,
actions are performed in the order of iteration (if an iteration order
is specified). Exceptions thrown by the action are relayed to the
caller.forEach
in interface Iterable<Long>
forEach
in class SpinedBuffer.OfPrimitive<Long,long[],LongConsumer>
consumer
- The action to be performed for each elementprotected long[][] newArrayArray(int size)
SpinedBuffer.OfPrimitive
newArrayArray
in class SpinedBuffer.OfPrimitive<Long,long[],LongConsumer>
public long[] newArray(int size)
SpinedBuffer.OfPrimitive
newArray
in class SpinedBuffer.OfPrimitive<Long,long[],LongConsumer>
protected int arrayLength(long[] array)
SpinedBuffer.OfPrimitive
arrayLength
in class SpinedBuffer.OfPrimitive<Long,long[],LongConsumer>
protected void arrayForEach(long[] array, int from, int to, LongConsumer consumer)
SpinedBuffer.OfPrimitive
arrayForEach
in class SpinedBuffer.OfPrimitive<Long,long[],LongConsumer>
public void accept(long i)
LongConsumer
accept
in interface LongConsumer
i
- the input argumentpublic long get(long index)
public PrimitiveIterator.OfLong iterator()
Iterable
T
.iterator
in interface Iterable<Long>
iterator
in class SpinedBuffer.OfPrimitive<Long,long[],LongConsumer>
public Spliterator.OfLong spliterator()
Iterable
Spliterator
over the elements described by this
Iterable
.spliterator
in interface Iterable<Long>
Spliterator
over the elements described by this
Iterable
.public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public boolean isEmpty()
public long count()
protected int chunkSize(int n)