Skip to content

Combination

Overview

An immutable combination that represents a subset of a set

@author Jonathan Olson <jonathan.olson@colorado.edu>

Class Combination

import { Combination } from 'scenerystack/dot';

Constructor

new Combination( inclusions : boolean[] )

Instance Methods

size() : number

includes( index : number ) : boolean

apply( array : T[] ) : T[]

Applies the combination to an array, returning a new array with the used elements.

inverted() : Combination

Creates a new combination that is the inverse of this (includes the opposite elements)

getIncludedIndices() : number[]

toString() : string

equals( combination : Combination ) : boolean

Instance Properties

inclusions : boolean[]

(readonly)

Static Methods

empty( size : number ) : Combination

Creates an empty combination of a given size.

full( size : number ) : Combination

Creates a full combination of a given size.

combinations( size : number ) : Combination[]

Lists all combinations from a given size

forEachCombination( 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

combinationsOf( array : T[] ) : T[][]

Source Code

See the source for Combination.ts in the dot repository.