Package ints

Class CharArray

  • All Implemented Interfaces:
    IntArray

    public final class CharArray
    extends java.lang.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.
      CharArray​(IntList il)
      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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int get​(int index)
      Returns the specified array element.
      int size()
      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 Detail

      • 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:
        java.lang.IllegalArgumentException - if (ba.length % 1) != 0
        java.lang.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:
        java.lang.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:
        java.lang.IllegalArgumentException - if (ia[j] < 0 || ia[j] > Character.MAX_VALUE) for any index j satisfying (j >= from && j < to)
        java.lang.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:
        java.lang.IllegalArgumentException - if (il.get(j) < 0 || il.get(j) > Character.MAX_VALUE) for any index j satisfying (j >= 0 && j < il.size())
        java.lang.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:
        java.lang.IllegalArgumentException - if (valueSize < 1) || (valueSize >= (Character.MAX_VALUE + 1))
        java.lang.IllegalArgumentException - if (ia[j] < 0 || ia[j] > valueSize) for any index j satisfying (j >= 0 && j < ia.length)
        java.lang.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:
        java.lang.IllegalArgumentException - if (valueSize < 1) || (valueSize >= (Character.MAX_VALUE + 1))
        java.lang.IllegalArgumentException - if (ia[j] < 0 || ia[j] > valueSize) for any index j satisfying (j >= 0 && j < ia.length)
        java.lang.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:
        java.lang.IllegalArgumentException - if (ia[j] < 0 || ia[j] > Character.MAX_VALUE) for any index j satisfying (j >= from && j < to)
        java.lang.IndexOutOfBoundsException - if (from < 0 || to > ia.length)
        java.lang.NegativeArraySizeException - if to > from
        java.lang.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:
        java.lang.IllegalArgumentException - if (il.get(j) < 0 || il.get(j) > Character.MAX_VALUE) for any index j satisfying (j >= from && j < to)
        java.lang.IndexOutOfBoundsException - if from < 0 || to > il.length
        java.lang.NegativeArraySizeException - if to > from
        java.lang.NullPointerException - if il == null
    • Method Detail

      • 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