Permutation¶
Overview¶
An immutable permutation that can permute an array
@author Jonathan Olson <jonathan.olson@colorado.edu>
Class Permutation¶
Constructor¶
new Permutation( indices : number[] )¶
Instance Methods¶
size() : number¶
apply( arrayOrInt : T ) : T extends E[] ? number[] : number¶
Applies the permutation, returning either a new array or number (whatever was provided).
inverted() : Permutation¶
Creates a new permutation that is the inverse of this.
withIndicesPermuted( indices : number[] ) : Permutation[]¶
toString() : string¶
equals( permutation : Permutation ) : boolean¶
Instance Properties¶
indices : number[]¶
(readonly)
Static Methods¶
identity( size : number ) : Permutation¶
Creates an identity permutation of a given size.
permutations( size : number ) : Permutation[]¶
Lists all permutations that have a given size
forEachPermutation( array : T[], callback : ( array: readonly T[] ) => void )¶
Calls a callback on every single possible permutation of the given Array
@param array @param callback - Called on each permuted version of the array possible
permutationsOf( array : T[] ) : T[][]¶
Source Code¶
See the source for Permutation.ts in the dot repository.