org.matheclipse.combinatoric.util
Class ArrayUtils
- java.lang.Object
-
- org.matheclipse.combinatoric.util.ArrayUtils
-
public final class ArrayUtils extends java.lang.ObjectProvides a couple of static utility methods for creating and initializing arrays used throughout permutation and combination generation.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static int[]deleteSubset(int[] multiset, int[] subset)Iterate over the elements in thesubsetand set the first elements to-1in themultisetwhich equals the subset elements.static int[]identityPermutation(int n)Creates and fills an array with a[i] = i.static voididentityPermutation(int[] a)Fills the given array with a[i] = i.static char[]valuesAt(char[] elements, int[] indices)static int[]valuesAt(int[] elements, int[] indices)static <T> T[]valuesAt(T[] elements, int[] indices)
-
-
-
Method Detail
-
deleteSubset
public static int[] deleteSubset(int[] multiset, int[] subset)Iterate over the elements in thesubsetand set the first elements to-1in themultisetwhich equals the subset elements. Return a new reduced multisetint[]array where the-1values are deleted.- Parameters:
multiset- a multiset containing equals or greater than elements as the subset.subset- a subset with the elements which should be deleted.- Returns:
-
identityPermutation
public static void identityPermutation(int[] a)
Fills the given array with a[i] = i. For example, if a = int[4], then fillsawith{ 0, 1, 2, 3 }. Used throughout permutation and combination generation as the first result (lexicographically).- Parameters:
a- an array
-
identityPermutation
public static int[] identityPermutation(int n)
Creates and fills an array with a[i] = i. For example, if n = 4, then returns{ 0, 1, 2, 3 }. Used throughout permutation and combination generation as the first result (lexicographically).- Parameters:
n- the size of the array- Returns:
- the initialized array
-
valuesAt
public static char[] valuesAt(char[] elements, int[] indices)- Parameters:
elements- the elements to choose fromindices- the array of indices- Returns:
- the mapped array
-
valuesAt
public static int[] valuesAt(int[] elements, int[] indices)- Parameters:
elements- the elements to choose fromindices- the array of indices- Returns:
- the mapped array
-
valuesAt
public static <T> T[] valuesAt(T[] elements, int[] indices)- Type Parameters:
T- a type- Parameters:
elements- the elements to choose fromindices- the array of indices- Returns:
- the mapped array
-
-
DMelt 3.0 © DataMelt by jWork.ORG