Class LongSequence

java.lang.Object
com.github.tommyettinger.random.LongSequence

public class LongSequence extends Object
A very basic append-only list of long items. This is used to store the sequence of results used by a KnownSequenceRandom, and can be produced by an ArchivalWrapper.
  • Field Details

    • items

      public long[] items
    • size

      public int size
    • NO_OP

      public static final LongSequence NO_OP
      This is a special single instance of a subclass of LongSequence; it doesn't store anything, and can't have its get(int) method called. The add(long) method does nothing here, and won't cause any memory to be allocated. This can be useful to assign to the ArchivalWrapper.archive field when you don't want it to do anything beyond a normal generator; then you can assign a "real" LongSequence when you want to start storing.
  • Constructor Details

    • LongSequence

      public LongSequence()
    • LongSequence

      public LongSequence(int initialCapacity)
    • LongSequence

      public LongSequence(LongSequence other)
    • LongSequence

      public LongSequence(long[] longs)
  • Method Details

    • get

      public long get(int index)
      Gets the long item at index, which must be at least 0 and less than size. This does not do any bounds checking beyond a possible ArrayIndexOutOfBoundsException that will be thrown if you give an index that is negative or greater than items.length (the capacity). If you request an index between size and items.length, this will return 0.
      Parameters:
      index - which item to retrieve; must be at least 0 and less than size
      Returns:
      the item at the specified index
    • add

      public void add(long item)
    • size

      public int size()
    • resize

      public void resize(int newCapacity)
    • clear

      public void clear()
    • copy

      public LongSequence copy()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • appendSerialized

      public StringBuilder appendSerialized(StringBuilder sb, com.github.tommyettinger.digital.Base base)
    • appendSerialized

      public StringBuilder appendSerialized(StringBuilder sb)
    • stringSerialize

      public String stringSerialize(com.github.tommyettinger.digital.Base base)
    • stringSerialize

      public String stringSerialize()
    • stringDeserialize

      public LongSequence stringDeserialize(String data, com.github.tommyettinger.digital.Base base)
    • stringDeserialize

      public LongSequence stringDeserialize(String data)
    • with

      public static LongSequence with(long item)
    • with

      public static LongSequence with(long... items)