Class StringArray

java.lang.Object
org.snpsift.annotate.mem.arrays.StringArrayBase
org.snpsift.annotate.mem.arrays.StringArray
All Implemented Interfaces:
Serializable, Iterable<String>

public class StringArray extends StringArrayBase
Implement a memory efficient array of strings 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 Details

    • MAX_NUM_STRING_TO_SHOW

      public static final int MAX_NUM_STRING_TO_SHOW
      See Also:
    • data

      protected byte[] data
    • index2offset

      protected int[] index2offset
    • offset

      protected int offset
  • Constructor Details

    • StringArray

      public StringArray(int numElements, int size)
      Constructor
      Parameters:
      numElements - : Number of elements in the array
      size - : Initial size of the array
  • Method Details

    • sizeOf

      public static int sizeOf(String s)
      Calculate the size of a string in memory
    • sizeOf

      public static int sizeOf(String[] strings)
    • sizeOf

      public static int sizeOf(Collection<String> strings)
    • of

      public static StringArray of(String[] strings)
      Create a StringArray from an array of strings
    • of

      public static StringArray of(Collection<String> strings)
      Create a StringArray from a collection of strings
    • get

      public String get(int i)
      Get the string at array index 'i'
      Specified by:
      get in class StringArrayBase
    • getOffset

      public int getOffset()
    • set

      public int set(int i, String str)
      Add a string to the array WARNING: Typically you use either 'add' or 'set', but not both
      Specified by:
      set in class StringArrayBase
    • size

      public int size()
      Size of the data array (capacity of number of bytes)
      Specified by:
      size in class StringArrayBase
    • sizeBytes

      public long sizeBytes()
      Memory size of this object (approximate size in bytes)
      Specified by:
      sizeBytes in class StringArrayBase
    • toString

      public String toString()
      Overrides:
      toString in class Object