next up previous contents index
Next: Three Tuples ( three_tuple Up: Simple Data Types and Previous: Some Useful Functions (

     
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/tuple.h >

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(A u, 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.
bool p == q equality test for two_tuples. Each of the component types must have an equality operator.
int  compare(two_tuple<A,B> p, two_tuple<A,B> q)
    lexicographic ordering for two_tuples. Each of the component types must have a compare function.
int  Hash(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: Some Useful Functions (
LEDA research project
1999-04-23