# Class StringArrayBase

java.lang.Object
org.snpsift.annotate.mem.arrays.StringArrayBase

All Implemented Interfaces:
  `Serializable, Iterable<String>`

Direct Known Subclasses:
  `EnumArray, StringArray`

public abstract class StringArrayBase extends Object implements Iterable<String>, Serializable
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:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`protected int`
`currentIndex`

## Constructor Summary

Constructors
Constructor
Description
`StringArrayBase()`
Constructor

## Method Summary

Modifier and Type
Method
Description
`void`
`add(String str)`
Add a string to the array WARNING: Typically you use either 'add' or 'set', but not both
`abstract String`
`get(int i)`
Get the string at array index 'i'
`Iterator<String>`
`iterator()`
`int`
`length()`
Number of ellements in the array
`abstract int`
`set(int i, String str)`
Add a string to the array Return the index of the next element
`abstract int`
`size()`
Number of different strings in the array
`abstract long`
`sizeBytes()`
Memory size of this object (approximate size in bytes)

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface 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

public void add(String str)
Add a string to the array WARNING: Typically you use either 'add' or 'set', but not both

### get

public abstract String get(int i)
Get the string at array index 'i'

### iterator

public Iterator<String> iterator()

Specified by:
  `iterator` in interface `Iterable<String>`

### length

public int length()
Number of ellements in the array

### set

public abstract int set(int i, String str)
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)