Class CollectionNumbers


  • public class CollectionNumbers
    extends Object
    Utilities to work with number collections.
    Author:
    carcassi
    • Method Detail

      • toList

        public static ListNumber toList​(Object values)
        Takes a primitive array and wraps it into the appropriate mutable array wrapper.
        Parameters:
        values - a primitive array (e.g. int[])
        Returns:
        a mutable wrapper
        Throws:
        IllegalArgumentException - if the given object is not a primitive array.
      • toListDouble

        public static ArrayDouble toListDouble​(double... values)
        Takes a double array and wraps it into an ArrayDouble.
        Parameters:
        values - a primitive array
        Returns:
        a mutable wrapper
        Throws:
        IllegalArgumentException - if the given object is not a primitive array.
      • toListFloat

        public static ArrayFloat toListFloat​(float... values)
        Takes a float array and wraps it into an ArrayFloat.
        Parameters:
        values - a primitive array
        Returns:
        a mutable wrapper
        Throws:
        IllegalArgumentException - if the given object is not a primitive array.
      • toListLong

        public static ArrayLong toListLong​(long... values)
        Takes a long array and wraps it into an ArrayLong.
        Parameters:
        values - a primitive array
        Returns:
        a mutable wrapper
        Throws:
        IllegalArgumentException - if the given object is not a primitive array.
      • toListULong

        public static ArrayULong toListULong​(long... values)
        Takes an unsigned long array and wraps it into an ArrayULong.
        Parameters:
        values - a primitive array
        Returns:
        a mutable wrapper
        Throws:
        IllegalArgumentException - if the given object is not a primitive array.
      • toListInt

        public static ArrayInteger toListInt​(int... values)
        Takes an int array and wraps it into an ArrayInteger.
        Parameters:
        values - a primitive array
        Returns:
        a mutable wrapper
        Throws:
        IllegalArgumentException - if the given object is not a primitive array.
      • toListUInt

        public static ArrayUInteger toListUInt​(int... values)
        Takes an unsigned int array and wraps it into an ArrayUInteger.
        Parameters:
        values - a primitive array
        Returns:
        a mutable wrapper
        Throws:
        IllegalArgumentException - if the given object is not a primitive array.
      • toListShort

        public static ArrayShort toListShort​(short... values)
        Takes a short array and wraps it into an ArrayShort.
        Parameters:
        values - a primitive array
        Returns:
        a mutable wrapper
        Throws:
        IllegalArgumentException - if the given object is not a primitive array.
      • toListUShort

        public static ArrayUShort toListUShort​(short... values)
        Takes an unsigned short array and wraps it into an ArrayUShort.
        Parameters:
        values - a primitive array
        Returns:
        a mutable wrapper
        Throws:
        IllegalArgumentException - if the given object is not a primitive array.
      • toListByte

        public static ArrayByte toListByte​(byte... values)
        Takes a byte array and wraps it into an ArrayByte.
        Parameters:
        values - a primitive array
        Returns:
        a mutable wrapper
        Throws:
        IllegalArgumentException - if the given object is not a primitive array.
      • toListUByte

        public static ArrayUByte toListUByte​(byte... values)
        Takes an unsigned byte array and wraps it into an ArrayUByte.
        Parameters:
        values - a primitive array
        Returns:
        a mutable wrapper
        Throws:
        IllegalArgumentException - if the given object is not a primitive array.
      • unmodifiableList

        public static ListNumber unmodifiableList​(ListNumber list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableList

        public static ListDouble unmodifiableList​(ListDouble list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableList

        public static ListFloat unmodifiableList​(ListFloat list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableList

        public static ListLong unmodifiableList​(ListLong list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableList

        public static ListInteger unmodifiableList​(ListInteger list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableList

        public static ListShort unmodifiableList​(ListShort list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableList

        public static ListByte unmodifiableList​(ListByte list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableList

        public static ArrayDouble unmodifiableList​(ArrayDouble list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableList

        public static ArrayFloat unmodifiableList​(ArrayFloat list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableList

        public static ArrayLong unmodifiableList​(ArrayLong list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableList

        public static ArrayInteger unmodifiableList​(ArrayInteger list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableList

        public static ArrayShort unmodifiableList​(ArrayShort list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableList

        public static ArrayByte unmodifiableList​(ArrayByte list)
        Returns an unmodifiable view of the specified list.
        Parameters:
        list - the list for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified list.
      • unmodifiableListDouble

        public static ArrayDouble unmodifiableListDouble​(double... values)
        Returns an unmodifiable ArrayDouble wrapper for the given double array.
        Parameters:
        values - a primitive array.
        Returns:
        an immutable wrapper.
      • unmodifiableListFloat

        public static ArrayFloat unmodifiableListFloat​(float... values)
        Returns an unmodifiable ArrayFloat wrapper for the given float array.
        Parameters:
        values - a primitive array.
        Returns:
        an immutable wrapper.
      • unmodifiableListLong

        public static ArrayLong unmodifiableListLong​(long... values)
        Returns an unmodifiable ArrayLong wrapper for the given long array.
        Parameters:
        values - a primitive array.
        Returns:
        an immutable wrapper.
      • unmodifiableListULong

        public static ArrayULong unmodifiableListULong​(long... values)
        Returns an unmodifiable ArrayULong wrapper for the given unsigned long array.
        Parameters:
        values - a primitive array.
        Returns:
        an immutable wrapper.
      • unmodifiableListInt

        public static ArrayInteger unmodifiableListInt​(int... values)
        Returns an unmodifiable ArrayInteger wrapper for the given int array.
        Parameters:
        values - a primitive array.
        Returns:
        an immutable wrapper.
      • unmodifiableListUInt

        public static ArrayUInteger unmodifiableListUInt​(int... values)
        Returns an unmodifiable ArrayUInteger wrapper for the given unsigned int array.
        Parameters:
        values - a primitive array.
        Returns:
        an immutable wrapper.
      • unmodifiableListShort

        public static ArrayShort unmodifiableListShort​(short... values)
        Returns an unmodifiable ArrayShort wrapper for the given short array.
        Parameters:
        values - a primitive array.
        Returns:
        an immutable wrapper.
      • unmodifiableListUShort

        public static ArrayUShort unmodifiableListUShort​(short... values)
        Returns an unmodifiable ArrayUShort wrapper for the given unsigned short array.
        Parameters:
        values - a primitive array.
        Returns:
        an immutable wrapper.
      • unmodifiableListByte

        public static ArrayByte unmodifiableListByte​(byte... values)
        Returns an unmodifiable ArrayByte wrapper for the given byte array.
        Parameters:
        values - a primitive array.
        Returns:
        an immutable wrapper.
      • unmodifiableListUByte

        public static ArrayUByte unmodifiableListUByte​(byte... values)
        Returns an unmodifiable ArrayUByte wrapper for the given unsigned byte array.
        Parameters:
        values - a primitive array.
        Returns:
        an immutable wrapper.
      • arrayCopy

        public static void arrayCopy​(CollectionNumber src,
                                     double[] dest,
                                     int destPos)
        Copies the content of the collection to an array at the desired position.
        Parameters:
        src - the source number collection.
        dest - the destination array.
        destPos - starting position in the destination array.
        Throws:
        IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
        NullPointerException - if either src or dest is null.
      • arrayCopy

        public static void arrayCopy​(CollectionNumber src,
                                     float[] dest,
                                     int destPos)
        Copies the content of the collection to an array at the desired position.
        Parameters:
        src - the source number collection.
        dest - the destination array.
        destPos - starting position in the destination array.
        Throws:
        IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
        NullPointerException - if either src or dest is null.
      • arrayCopy

        public static void arrayCopy​(CollectionNumber src,
                                     long[] dest,
                                     int destPos)
        Copies the content of the collection to an array at the desired position.
        Parameters:
        src - the source number collection.
        dest - the destination array.
        destPos - starting position in the destination array.
        Throws:
        IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
        NullPointerException - if either src or dest is null.
      • arrayCopy

        public static void arrayCopy​(CollectionNumber src,
                                     int[] dest,
                                     int destPos)
        Copies the content of the collection to an array at the desired position.
        Parameters:
        src - the source number collection.
        dest - the destination array.
        destPos - starting position in the destination array.
        Throws:
        IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
        NullPointerException - if either src or dest is null.
      • arrayCopy

        public static void arrayCopy​(CollectionNumber src,
                                     short[] dest,
                                     int destPos)
        Copies the content of the collection to an array at the desired position.
        Parameters:
        src - the source number collection.
        dest - the destination array.
        destPos - starting position in the destination array.
        Throws:
        IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
        NullPointerException - if either src or dest is null.
      • arrayCopy

        public static void arrayCopy​(CollectionNumber src,
                                     byte[] dest,
                                     int destPos)
        Copies the content of the collection to an array at the desired position.
        Parameters:
        src - the source number collection.
        dest - the destination array.
        destPos - starting position in the destination array.
        Throws:
        IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
        NullPointerException - if either src or dest is null.