Class: Combination
Defined in: combinations/combination.ts:82
A class representing a combination of values.
The class stores unique values and exposes deterministic sorted values, lexicographic rank helpers, set-style predicates, and ordering helpers.
Param
The values of the combination.
Param
The lexicographic rank of the combination.
Param
The starting offset for combination values.
Examples
const combination = new Combination([12, 3, 42, 6, 22]);
combination.values; // [3, 6, 12, 22, 42]
combination.rank; // 755560
Extended by
Constructors
Constructor
new Combination(
values?,__namedParameters?):Combination
Defined in: combinations/combination.ts:91
Parameters
values?
CombinationInputWithRank | CombinationInputValues | null
__namedParameters?
CombinationOptions = {}
Returns
Combination
Properties
_rank
protected_rank:number|null
Defined in: combinations/combination.ts:85
_start
protectedreadonly_start:number
Defined in: combinations/combination.ts:87
_values
protectedreadonly_values:Set\<number>
Defined in: combinations/combination.ts:83
Accessors
length
Get Signature
get length():
number
Defined in: combinations/combination.ts:180
Get number of values.
Example
Returns
number
Number of unique values in the combination.
rank
Get Signature
get rank():
number
Defined in: combinations/combination.ts:155
Get lexicographic rank.
If rank is not explicitly provided, it is computed lazily from values.
Example
Returns
number
Lexicographic rank.
start
Get Signature
get start():
number
Defined in: combinations/combination.ts:192
Get the starting offset of the combination.
Example
Returns
number
Start offset.
storedRank
Get Signature
get storedRank():
number|null
Defined in: combinations/combination.ts:168
Get the stored rank without triggering lazy rank computation.
Returns
number | null
Stored rank or null when it has not been set/computed yet.
values
Get Signature
get values():
CombinationValues
Defined in: combinations/combination.ts:137
Get sorted combination values.
Example
Returns
Sorted values.
Methods
[iterator]()
[iterator]():
Iterator\<number>
Defined in: combinations/combination.ts:444
Returns
Iterator\<number>
compares()
compares(
combination):number
Defined in: combinations/combination.ts:358
Compare this combination to another combination or rank.
Parameters
combination
Candidate combination/rank.
Returns
number
-1, 0, or 1.
Example
copy()
copy(
values?):Combination
Defined in: combinations/combination.ts:209
Return a copy with optional modifications.
Parameters
values?
Replacement values. null keeps current values. If an integer is provided,
it is treated as the lexicographic rank of the combination.
Returns
Combination
A new Combination.
Example
const base = new Combination([4, 5, 6], { start: 1 });
base.copy({ values: [2, 3, 4] }).values; // [2, 3, 4]
equals()
equals(
combination):boolean
Defined in: combinations/combination.ts:257
Check whether this combination equals another combination or rank.
Parameters
combination
Candidate combination/rank.
Returns
boolean
true when values/rank are equal.
Example
get()
get(
index):number
Defined in: combinations/combination.ts:408
Get a value by index.
Parameters
index
number
Zero-based value index.
Returns
number
Value at index.
Throws
Thrown when index is out of bounds.
getValues()
getValues(
start?):CombinationValues
Defined in: combinations/combination.ts:237
Get values with an optional start offset transformation.
Parameters
start?
number
Optional target start offset.
Returns
Values adjusted to the requested start offset.
Example
hashCode()
hashCode():
number
Defined in: combinations/combination.ts:424
Get an integer hash representation.
Returns
number
Rank-based hash.
Example
includes()
includes(
combination):boolean
Defined in: combinations/combination.ts:292
Check whether this combination includes another combination or a value.
Parameters
combination
Candidate value(s).
number | CombinationInputValues | null | undefined
Returns
boolean
true when all candidate values are included.
Example
intersection()
intersection(
combination):Combination
Defined in: combinations/combination.ts:340
Get the intersection with another combination.
Parameters
combination
Candidate value(s).
CombinationInputValues | null | undefined
Returns
Combination
A new Combination containing shared values.
Example
intersects()
intersects(
combination):boolean
Defined in: combinations/combination.ts:318
Check whether this combination intersects another combination.
Parameters
combination
Candidate value(s).
CombinationInputValues | null | undefined
Returns
boolean
true when at least one value overlaps.
Example
similarity()
similarity(
combination):number
Defined in: combinations/combination.ts:388
Calculate similarity ratio with another combination.
Parameters
combination
Candidate values.
CombinationInputValues | null | undefined
Returns
number
Similarity ratio in [0, 1].
Example
toRepr()
toRepr():
string
Defined in: combinations/combination.ts:436
Return a string representation.
Returns
string
Representation string.
Example
toString()
toString():
string
Defined in: combinations/combination.ts:440
Returns
string