Class ArrayUtils

java.lang.Object
dk.jonaslindstrom.ruffini.common.util.ArrayUtils

public class ArrayUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int[]
    append(int a, int[] list)
     
    static int[]
    concat(int[] a, int[] b)
     
    static java.util.stream.Stream<int[]>
    ksubsets(int k, int r)
    Return a stream of all k-subsets of {0,1,2,...,r-1} in lexicographical order
    static java.util.stream.Stream<int[]>
    ksubsets(int k, int[] set)
     
    static <E> java.util.stream.Stream<List<E>>
    ksubsets(int k, List<E> set)
     
    static java.util.stream.Stream<int[]>
    Return all nonempty subsets of {0,1,2,...,r-1} lexicographical order.
    static java.util.stream.Stream<int[]>
    nonEmptySubsets(int[] set)
     
    static <E> ArrayList<E>
    populate(int n, java.util.function.IntFunction<E> populator)
     
    static int[]
    prepend(int a, int[] list)
     
    static int[]
    remove(int[] list, int i)
    Return a new array which is a copy of the original one except that the element with index i is excluded.
    static int[]
    remove(int[] list, int[] indices)
    Returns a new array which contains all elements from the original array except for a given set of indices.
    static int[]
    removeElements(int[] list, int[] elements)
    Return a new list where a list of elements are not included.
    static byte[]
    reverse(byte[] bytes)
    Return a copy of the given array with the entries in reversed order
    static int[]
    sublist(int[] list, int[] indices)
     
    static <E> List<E>
    sublist(List<E> list, int[] indices)
     
    static java.util.stream.Stream<int[]>
    subsets(int r)
    Return all subsets of {0,1,2,...,r-1} lexicographical order.
    static java.util.stream.Stream<int[]>
    subsets(int[] set)
     
    static <E> java.util.stream.Stream<List<E>>
    subsets(List<E> set)
    Return all subsets of the array in lexicographical order of the indices.
    static int[]
    union(int[] I, int[] J)
    Return a list with all the elements of a and b occuring exactly once.

    Methods inherited from class java.lang.Object

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

    • ArrayUtils

      public ArrayUtils()
  • Method Details

    • prepend

      public static int[] prepend(int a, int[] list)
    • append

      public static int[] append(int a, int[] list)
    • concat

      public static int[] concat(int[] a, int[] b)
    • remove

      public static int[] remove(int[] list, int i)
      Return a new array which is a copy of the original one except that the element with index i is excluded.
      Parameters:
      list -
      i -
      Returns:
    • removeElements

      public static int[] removeElements(int[] list, int[] elements)
      Return a new list where a list of elements are not included. It is assumes that both the list and the list of elements to be removed are sorted and that all the elements to be removed are in the original list.
      Parameters:
      list -
      elements -
      Returns:
    • remove

      public static int[] remove(int[] list, int[] indices)
      Returns a new array which contains all elements from the original array except for a given set of indices. It is assumed that the list and list of indices are sorted and that all indices are in the range.
      Parameters:
      list -
      indices -
      Returns:
    • populate

      public static <E> ArrayList<E> populate(int n, java.util.function.IntFunction<E> populator)
    • subsets

      public static <E> java.util.stream.Stream<List<E>> subsets(List<E> set)
      Return all subsets of the array in lexicographical order of the indices.
      Parameters:
      set -
      Returns:
    • subsets

      public static java.util.stream.Stream<int[]> subsets(int[] set)
    • subsets

      public static java.util.stream.Stream<int[]> subsets(int r)
      Return all subsets of {0,1,2,...,r-1} lexicographical order.
      Parameters:
      r -
      Returns:
    • nonEmptySubsets

      public static java.util.stream.Stream<int[]> nonEmptySubsets(int r)
      Return all nonempty subsets of {0,1,2,...,r-1} lexicographical order.
      Parameters:
      r -
      Returns:
    • nonEmptySubsets

      public static java.util.stream.Stream<int[]> nonEmptySubsets(int[] set)
    • ksubsets

      public static java.util.stream.Stream<int[]> ksubsets(int k, int r)
      Return a stream of all k-subsets of {0,1,2,...,r-1} in lexicographical order
      Parameters:
      k -
      r -
      Returns:
    • sublist

      public static <E> List<E> sublist(List<E> list, int[] indices)
    • sublist

      public static int[] sublist(int[] list, int[] indices)
    • ksubsets

      public static <E> java.util.stream.Stream<List<E>> ksubsets(int k, List<E> set)
    • ksubsets

      public static java.util.stream.Stream<int[]> ksubsets(int k, int[] set)
    • union

      public static int[] union(int[] I, int[] J)
      Return a list with all the elements of a and b occuring exactly once. Assumes that both arrays are sorted.
      Parameters:
      I -
      J -
      Returns:
    • reverse

      public static byte[] reverse(byte[] bytes)
      Return a copy of the given array with the entries in reversed order