Package ints

Class CharArray

java.lang.Object
ints.CharArray
All Implemented Interfaces:
IntArray

public final class CharArray extends Object implements IntArray
/**

Class UnsignedByteArray represents an immutable array of integer values between 0 and 65,535 inclusive that is stored as a char[] array.

Instances of CharArray are immutable.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CharArray(byte[] ba)
    Constructs a new CharArray instance from the specified data.
    CharArray(char[] ca)
    Constructs a new CharArray instance from the specified data.
    CharArray(int[] ia)
    Constructs a new CharArray instance from the specified data.
    CharArray(int[] ia, int valueSize)
    Constructs a new CharArray instance from the specified data.
    CharArray(int[] ia, int to, int from)
    Constructs a new CharArray instance from the specified data.
    Constructs a new UnsignedByteArray instance from the specified data.
    CharArray(IntList il, int valueSize)
    Constructs a new CharArray instance from the specified data.
    CharArray(IntList il, int from, int to)
    Constructs a new CharArray instance from the specified data.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    get(int index)
    Returns the specified array element.
    int
    Returns the number of elements in this IntArray.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CharArray

      public CharArray(byte[] ba)
      Constructs a new CharArray instance from the specified data. The array of bytes is interpreted as a stream of characters with the high byte preceding the low byte.
      Parameters:
      ba - an array of char values expressed as pairs of bytes.
      Throws:
      IllegalArgumentException - if (ba.length % 1) != 0
      NullPointerException - if ca == null
    • CharArray

      public CharArray(char[] ca)
      Constructs a new CharArray instance from the specified data.
      Parameters:
      ca - an array of integer values between 0 and Character.MAX_VALUE inclusive
      Throws:
      NullPointerException - if ca == null
    • CharArray

      public CharArray(int[] ia)
      Constructs a new CharArray instance from the specified data.
      Parameters:
      ia - an array of integers
      Throws:
      IllegalArgumentException - if (ia[j] < 0 || ia[j] > Character.MAX_VALUE) for any index j satisfying (j >= from && j < to)
      NullPointerException - if ia == null
    • CharArray

      public CharArray(IntList il)
      Constructs a new UnsignedByteArray instance from the specified data.
      Parameters:
      il - an list of integer values between 0 and Character.MAX_VALUE inclusive
      Throws:
      IllegalArgumentException - if (il.get(j) < 0 || il.get(j) > Character.MAX_VALUE) for any index j satisfying (j >= 0 && j < il.size())
      NullPointerException - if il == null
    • CharArray

      public CharArray(int[] ia, int valueSize)
      Constructs a new CharArray instance from the specified data.
      Parameters:
      ia - an array of nonnegative integers
      valueSize - the exclusive end of the range of non-negative array values
      Throws:
      IllegalArgumentException - if (valueSize < 1) || (valueSize >= (Character.MAX_VALUE + 1))
      IllegalArgumentException - if (ia[j] < 0 || ia[j] > valueSize) for any index j satisfying (j >= 0 && j < ia.length)
      NullPointerException - if ia == null
    • CharArray

      public CharArray(IntList il, int valueSize)
      Constructs a new CharArray instance from the specified data.
      Parameters:
      il - an list of nonnegative integer
      valueSize - the exclusive end of the range of non-negative array values
      Throws:
      IllegalArgumentException - if (valueSize < 1) || (valueSize >= (Character.MAX_VALUE + 1))
      IllegalArgumentException - if (ia[j] < 0 || ia[j] > valueSize) for any index j satisfying (j >= 0 && j < ia.length)
      NullPointerException - if il == null
    • CharArray

      public CharArray(int[] ia, int to, int from)
      Constructs a new CharArray instance from the specified data.
      Parameters:
      ia - an array of integer values between 0 and Character.MAX_VALUE inclusive
      to - the first element to be included (inclusive)
      from - the last element to be included (exclusive)
      Throws:
      IllegalArgumentException - if (ia[j] < 0 || ia[j] > Character.MAX_VALUE) for any index j satisfying (j >= from && j < to)
      IndexOutOfBoundsException - if (from < 0 || to > ia.length)
      NegativeArraySizeException - if to > from
      NullPointerException - if ia == null
    • CharArray

      public CharArray(IntList il, int from, int to)
      Constructs a new CharArray instance from the specified data.
      Parameters:
      il - an list of integer values between 0 and Character.MAX_VALUE inclusive
      from - the first element to be included (inclusive)
      to - the last element to be included (exclusive)
      Throws:
      IllegalArgumentException - if (il.get(j) < 0 || il.get(j) > Character.MAX_VALUE) for any index j satisfying (j >= from && j < to)
      IndexOutOfBoundsException - if from < 0 || to > il.length
      NegativeArraySizeException - if to > from
      NullPointerException - if il == null
  • Method Details

    • size

      public int size()
      Description copied from interface: IntArray
      Returns the number of elements in this IntArray.
      Specified by:
      size in interface IntArray
      Returns:
      the number of elements in this IntArray
    • get

      public int get(int index)
      Description copied from interface: IntArray
      Returns the specified array element.
      Specified by:
      get in interface IntArray
      Parameters:
      index - an array index
      Returns:
      the specified array element