next up previous contents index
Next: Three Tuples ( three_tuple Up: Simple Data Types and Previous: Counter ( counter )   Contents   Index


Two Tuples ( two_tuple )

Definition

An instance p of type two_tuple<A,B> is a two-tuple (a, b) of variables of types A , and B , respectively.

Related types are two_tuple, three_tuple, and four_tuple.

#include < LEDA/core/tuple.h >

Types

two_tuple< A,B> ::first_type the type of the first component.

two_tuple< A,B> ::second_type the type of the second component.

Creation

two_tuple< A,B> p creates an instance p of type two_tuple<A,B>. All components are initialized to their default value.

two_tuple< A,B> p(const A& u, const B& v) creates an instance p of type two_tuple<A,B> and initializes it with the value (u, v) .

Operations

A& p.first() returns the A -component of p. If p is a const-object the return type is A .

B& p.second() returns the B -component of p. If p is a const-object the return type is B .

template < class A, class B>
bool const two_tuple< A,B> & p == const two_tuple< A,B> & q
    equality test for two_tuples. Each of the component types must have an equality operator.

template < class A, class B>
int compare(const two_tuple< A,B> & p, const two_tuple< A,B> & q)
    lexicographic ordering for two_tuples. Each of the component types must have a compare function.

template < class A, class B>
int Hash(const two_tuple< A,B> & p)
    hash function for two_tuples. Each of the component types must have a Hash function.

Implementation

The obvious implementation is used.


next up previous contents index
Next: Three Tuples ( three_tuple Up: Simple Data Types and Previous: Counter ( counter )   Contents   Index
Christian Uhrig 2017-04-07