Package org.HdrHistogram.packedarray
Class AbstractPackedLongArray
- java.lang.Object
-
- org.HdrHistogram.packedarray.AbstractPackedLongArray
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<java.lang.Long>
- Direct Known Subclasses:
PackedLongArray
abstract class AbstractPackedLongArray extends java.lang.Object implements java.lang.Iterable<java.lang.Long>, java.io.Serializable
A Packed array of signed 64 bit values, and supportsget()
,set()
,add()
andincrement()
operations on the logical contents of the array.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
AbstractPackedLongArray.AllValuesIterator
-
Field Summary
Fields Modifier and Type Field Description private AbstractPackedArrayContext
arrayContext
private long
endTimeStampMsec
(package private) static int
NUMBER_OF_NON_ZEROS_TO_HASH
private static int
NUMBER_OF_SETS
AnAbstractPackedLongArray
UsesAbstractPackedArrayContext
to track the array's logical contents.private long
startTimeStampMsec
-
Constructor Summary
Constructors Constructor Description AbstractPackedLongArray()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
add(int index, long value)
Add to a value at a virtual index in the arrayvoid
add(AbstractPackedLongArray other)
Add the contents of the other array to this onevoid
clear()
Clear the array contents(package private) abstract void
clearContents()
abstract AbstractPackedLongArray
copy()
Create a copy of this array, complete with data and everything.(package private) abstract long
criticalSectionEnter()
(package private) abstract void
criticalSectionExit(long criticalValueAtEnter)
boolean
equals(java.lang.Object other)
Determine if this array is equivalent to another.long
get(int index)
Get value at virtual index in the array(package private) AbstractPackedArrayContext
getArrayContext()
long
getEndTimeStamp()
get the end time stamp [optionally] stored with this arrayint
getPhysicalLength()
Get the current physical length (in longs) of the array's backing storagelong
getStartTimeStamp()
get the start time stamp [optionally] stored with this arrayint
hashCode()
void
increment(int index)
Increment value at a virrual index in the arrayjava.util.Iterator<java.lang.Long>
iterator()
An Iterator over all values in the arrayint
length()
Get the (virtual) length of the arrayjava.lang.Iterable<IterationValue>
nonZeroValues()
An Iterator over all non-Zero values in the arrayprivate int
oneAtATimeHashStep(int incomingHash, int v)
(package private) abstract void
resizeStorageArray(int newPhysicalLengthInLongs)
void
set(int index, long value)
Set the value at a virtual index in the array(package private) void
setArrayContext(AbstractPackedArrayContext newArrayContext)
void
setEndTimeStamp(long timeStampMsec)
Set the end time stamp value associated with this array to a given value.void
setStartTimeStamp(long timeStampMsec)
Set the start time stamp value associated with this array to a given value.abstract void
setVirtualLength(int newVirtualArrayLength)
Set a new virtual length for the array.java.lang.String
toString()
-
-
-
Field Detail
-
NUMBER_OF_SETS
private static final int NUMBER_OF_SETS
AnAbstractPackedLongArray
UsesAbstractPackedArrayContext
to track the array's logical contents. Contexts may be switched when a context requires resizing to complete logical array operations (get, set, add, increment). Contexts are established and used within critical sections in order to facilitate concurrent implementors.- See Also:
- Constant Field Values
-
arrayContext
private AbstractPackedArrayContext arrayContext
-
startTimeStampMsec
private long startTimeStampMsec
-
endTimeStampMsec
private long endTimeStampMsec
-
NUMBER_OF_NON_ZEROS_TO_HASH
static final int NUMBER_OF_NON_ZEROS_TO_HASH
- See Also:
- Constant Field Values
-
-
Method Detail
-
getArrayContext
AbstractPackedArrayContext getArrayContext()
-
setArrayContext
void setArrayContext(AbstractPackedArrayContext newArrayContext)
-
getStartTimeStamp
public long getStartTimeStamp()
get the start time stamp [optionally] stored with this array- Returns:
- the start time stamp [optionally] stored with this array
-
setStartTimeStamp
public void setStartTimeStamp(long timeStampMsec)
Set the start time stamp value associated with this array to a given value.- Parameters:
timeStampMsec
- the value to set the time stamp to, [by convention] in msec since the epoch.
-
getEndTimeStamp
public long getEndTimeStamp()
get the end time stamp [optionally] stored with this array- Returns:
- the end time stamp [optionally] stored with this array
-
setEndTimeStamp
public void setEndTimeStamp(long timeStampMsec)
Set the end time stamp value associated with this array to a given value.- Parameters:
timeStampMsec
- the value to set the time stamp to, [by convention] in msec since the epoch.
-
setVirtualLength
public abstract void setVirtualLength(int newVirtualArrayLength)
Set a new virtual length for the array.- Parameters:
newVirtualArrayLength
- the
-
copy
public abstract AbstractPackedLongArray copy()
Create a copy of this array, complete with data and everything.- Returns:
- A distinct copy of this array.
-
resizeStorageArray
abstract void resizeStorageArray(int newPhysicalLengthInLongs)
-
clearContents
abstract void clearContents()
-
criticalSectionEnter
abstract long criticalSectionEnter()
-
criticalSectionExit
abstract void criticalSectionExit(long criticalValueAtEnter)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
get
public long get(int index)
Get value at virtual index in the array- Parameters:
index
- the virtual array index- Returns:
- the array value at the virtual index given
-
increment
public void increment(int index)
Increment value at a virrual index in the array- Parameters:
index
- virtual index of value to increment
-
add
public void add(int index, long value)
Add to a value at a virtual index in the array- Parameters:
index
- the virtual index of the value to be added tovalue
- the value to add
-
set
public void set(int index, long value)
Set the value at a virtual index in the array- Parameters:
index
- the virtual index of the value to setvalue
- the value to set
-
add
public void add(AbstractPackedLongArray other)
Add the contents of the other array to this one- Parameters:
other
- The to add to this array
-
clear
public void clear()
Clear the array contents
-
getPhysicalLength
public int getPhysicalLength()
Get the current physical length (in longs) of the array's backing storage- Returns:
- the current physical length (in longs) of the array's current backing storage
-
length
public int length()
Get the (virtual) length of the array- Returns:
- the (virtual) length of the array
-
iterator
public java.util.Iterator<java.lang.Long> iterator()
An Iterator over all values in the array- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.Long>
- Returns:
- an Iterator over all values in the array
-
nonZeroValues
public java.lang.Iterable<IterationValue> nonZeroValues()
An Iterator over all non-Zero values in the array- Returns:
- an Iterator over all non-Zero values in the array
-
equals
public boolean equals(java.lang.Object other)
Determine if this array is equivalent to another.- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
- the other array to compare to- Returns:
- True if this array are equivalent with the other.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
oneAtATimeHashStep
private int oneAtATimeHashStep(int incomingHash, int v)
-
-