Package org.snpsift.annotate.mem.arrays
Class StringArrayBase
java.lang.Object
org.snpsift.annotate.mem.arrays.StringArrayBase
- All Implemented Interfaces:
Serializable,Iterable<String>
- Direct Known Subclasses:
EnumArray,StringArray
Abstract base class for a string array that supports iteration and serialization.
This class provides a framework for managing a collection of strings with methods to add, get, and set elements.
The class maintains an internal index to keep track of the current position in the array.
It also provides an iterator to traverse the elements in the array.
Limitations:
- The class is abstract and requires concrete implementations to define the storage mechanism for the strings.
- The 'add' and 'set' methods are not intended to be used together; typically, you should use one or the other.
- The size of the array is managed by the implementing class, and the memory size calculation is approximate.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a string to the array WARNING: Typically you use either 'add' or 'set', but not bothabstract Stringget(int i) Get the string at array index 'i'iterator()intlength()Number of ellements in the arrayabstract intAdd a string to the array Return the index of the next elementabstract intsize()Number of different strings in the arrayabstract longMemory size of this object (approximate size in bytes)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
currentIndex
protected int currentIndex
-
-
Constructor Details
-
StringArrayBase
public StringArrayBase()Constructor- Parameters:
numElements- : Number of elements in the array
-
-
Method Details
-
add
Add a string to the array WARNING: Typically you use either 'add' or 'set', but not both -
get
Get the string at array index 'i' -
iterator
-
length
public int length()Number of ellements in the array -
set
Add a string to the array Return the index of the next element -
size
public abstract int size()Number of different strings in the array -
sizeBytes
public abstract long sizeBytes()Memory size of this object (approximate size in bytes)
-