next up previous contents index
Next: A date interface ( Up: Simple Data Types and Previous: Three Tuples ( three_tuple   Contents   Index


Four Tuples ( four_tuple )

Definition

An instance p of type four_tuple<A,B,C,D> is a four-tuple (a, b, c, d ) of variables of types A, B, C, and D, respectively.

Related types are two_tuple, three_tuple, and four_tuple.

#include < LEDA/core/tuple.h >

Types

four_tuple<A,B,C,D>::first_type the type of the first component.

four_tuple<A,B,C,D>::second_type the type of the second component.

four_tuple<A,B,C,D>::third_type the type of the third component.

four_tuple<A,B,C,D>::fourth_type the type of the fourth component.

Creation

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

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

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.

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

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

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

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

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

Implementation

The obvious implementation is used.

Example

We customize four_tuples and define a h_array for them.

#define prio() first()
#define inf()  second()
#define pq_item() third()
#define part_item() fourth()
typedef four_tuple<int,int,int,int> my_qu;

my_qu q; 
my_qu q1(2,2,0,0);
q.prio() = 5;

h_array<my_qu,int> M;
M[my_qu(2,2,nil,nil)] = 5;


next up previous contents index
Next: A date interface ( Up: Simple Data Types and Previous: Three Tuples ( three_tuple   Contents   Index