Constructor
new Pair(first, second)
The constructor for the class Pair.
Parameters:
Name | Type | Description |
---|---|---|
first |
* | The first element of the pair. |
second |
* | The second element of the pair. |
Methods
(static) createUniquePairs(array) → {array}
Creates unique paris from an array. The array must contain unique values.
Parameters:
Name | Type | Description |
---|---|---|
array |
array | An array containing unique values. |
Returns:
An array containing unique pairs created from the provided array.
- Type
- array
contains(item) → {boolean}
Checks whether or not this pair contains an object. Uses '===' to compare.
Parameters:
Name | Type | Description |
---|---|---|
item |
* | An string or a number (current limitation). |
Returns:
A boolean representing whether or not this pair contains a given value.
- Type
- boolean
getHash() → {number}
Returns a unique hash for this pair. Uses the cantor pairing function.
Returns:
The hash.
- Type
- number