Pair

Pair

A class representing a pair

Constructor

new Pair(first, second)

Source:

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}

Source:

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}

Source:

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}

Source:

Returns a unique hash for this pair. Uses the cantor pairing function.

Returns:

The hash.

Type
number