next up previous contents index
Next: Three Tuples ( three_tuple Up: Simple Data Types 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 >

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(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.

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

template <class A, class B>
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.

template <class A, class B>
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 Previous: Some Useful Functions (

© Copyright 1995-2002, Algorithmic Solutions Software GmbH. All rights reserved.
2002-10-16