Skip to content

Pair

Spice
import "std/data/pair";

Pair<V1, V2> struct

A pair in Spice is a commonly used data structure, which saves two values of arbitrary type together in a correlation

Constructors

ctor

Spice
public inline p Pair.ctor(V1 first, V2 second)

Construct a pair from two values

Parameters

Name Type Description
first V1 First value
second V2 Second value

Methods

getFirst

Spice
public inline f<V1&> Pair.getFirst()

Retrieve the first value of the pair

Returns: V1& — Reference to the first value

getSecond

Spice
public inline f<V2&> Pair.getSecond()

Retrieve the second value of the pair

Returns: V2& — Reference to the second value

setFirst

Spice
public inline p Pair.setFirst(const V1& first)

Set the first value of the pair

Parameters

Name Type Description
first const V1& New first value

setSecond

Spice
public inline p Pair.setSecond(const V2& second)

Set the second value of the pair

Parameters

Name Type Description
second const V2& New second value

Operators

operator==

Spice
public f<bool> operator==<V1, V2>(const Pair<V1, V2>& lhs, const Pair<V1, V2>& rhs)

Check if two pairs are equal, i.e. both of their values are equal

Parameters

Name Type Description
lhs const Pair<V1, V2>&
rhs const Pair<V1, V2>&

Returns: bool — Equal or not equal

operator!=

Spice
public f<bool> operator!=<V1, V2>(const Pair<V1, V2>& lhs, const Pair<V1, V2>& rhs)

Check if two pairs are not equal

Parameters

Name Type Description
lhs const Pair<V1, V2>&
rhs const Pair<V1, V2>&

Returns: bool — Not equal or equal