Package org.snpsift.annotate.mem.arrays
Class EnumArray
java.lang.Object
org.snpsift.annotate.mem.arrays.StringArrayBase
org.snpsift.annotate.mem.arrays.EnumArray
- All Implemented Interfaces:
Serializable
,Iterable<String>
Implement a memory efficient array of enums
It only stores bytes (i.e. UTF-8 encoding) and uses a single byte to mark the end of a string ('\0')
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]
static final int
static final int
Fields inherited from class org.snpsift.annotate.mem.arrays.StringArrayBase
currentIndex
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Add an enum, return the ordinalget
(int i) Get the string at array index 'i'int
getOrd
(int i) Get the ordinal at array index 'i'int
numEnums()
Number of enums in the arrayint
Add a string to the array WARNING: Typically you use either 'add' or 'set', but not bothint
size()
Size of the data array (capacity of number of bytes)long
Memory size of this object (approximate size in bytes)toString()
Methods inherited from class org.snpsift.annotate.mem.arrays.StringArrayBase
add, iterator, length
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
MAX_NUM_STRING_TO_SHOW
public static final int MAX_NUM_STRING_TO_SHOW- See Also:
-
MAX_NUMBER_OF_ENUM_VALUES
public static final int MAX_NUMBER_OF_ENUM_VALUES- See Also:
-
data
protected byte[] data -
ord2enum
-
enum2ord
-
-
Constructor Details
-
EnumArray
Constructor for using an array of strings- Parameters:
data
-
-
EnumArray
public EnumArray(int numElements) Constructor- Parameters:
numElements
- : Number of elements in the array
-
-
Method Details
-
addEnum
Add an enum, return the ordinal -
get
Get the string at array index 'i'- Specified by:
get
in classStringArrayBase
-
getOrd
public int getOrd(int i) Get the ordinal at array index 'i' -
numEnums
public int numEnums()Number of enums in the array -
set
Add a string to the array WARNING: Typically you use either 'add' or 'set', but not both- Specified by:
set
in classStringArrayBase
-
size
public int size()Size of the data array (capacity of number of bytes)- Specified by:
size
in classStringArrayBase
-
sizeBytes
public long sizeBytes()Memory size of this object (approximate size in bytes)- Specified by:
sizeBytes
in classStringArrayBase
-
toString
-