~zorba-coders/zorba/bug-950621

« back to all changes in this revision

Viewing changes to src/util/triple.h

  • Committer: brantmat at ETHZ
  • Date: 2007-10-09 12:58:38 UTC
  • Revision ID: svn-v4:8046edc3-af21-0410-8661-ec7318497eea:trunk/zorba:904
commit of the new directory structure

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; indent-tabs-mode: nil; tab-width: 2 -*-
 
2
 *
 
3
 *  $Id: triple.h,v 1.1 2006/10/09 07:07:59 Paul Pedersen Exp $
 
4
 *
 
5
 *      Copyright 2006-2007 FLWOR Foundation.
 
6
 *
 
7
 *  Author: Paul Pedersen
 
8
 *
 
9
 */
 
10
 
 
11
#ifndef XQP_TRIPLE_H
 
12
#define XQP_TRIPLE_H
 
13
 
 
14
namespace xqp {
 
15
 
 
16
template<class _T1, class _T2, class _T3>
 
17
class triple
 
18
{
 
19
public:
 
20
        _T1 first;            
 
21
        _T2 second;          
 
22
        _T3 third;          
 
23
 
 
24
public:
 
25
        triple() : first(), second(), third() { }
 
26
 
 
27
        triple(const _T1& _a, const _T2& _b, const _T3& _c)
 
28
        : first(_a), second(_b), third(_c) { }
 
29
 
 
30
        template<class _U1, class _U2, class _U3>
 
31
        triple(const triple<_U1, _U2, _U3>& _p)
 
32
        : first(_p.first), second(_p.second), third(_p.third) { }
 
33
};
 
34
 
 
35
template<class _T1, class _T2, class _T3>
 
36
inline bool operator==(
 
37
        const triple<_T1, _T2, _T3>& _x,
 
38
        const triple<_T1, _T2, _T3>& _y)
 
39
{
 
40
        return _x.first  == _y.first
 
41
                        && _x.second == _y.second
 
42
                        && _x.third  == _y.third;
 
43
}
 
44
 
 
45
template<class _T1, class _T2, class _T3>
 
46
inline bool operator<(
 
47
        const triple<_T1, _T2, _T3>& _x,
 
48
        const triple<_T1, _T2, _T3>& _y)
 
49
{
 
50
        return (_x.first < _y.first)
 
51
                        || ((_y.first == _x.first) && (_x.second < _y.second))
 
52
                        || ((_y.first == _x.first) && (_y.second == _x.second) && (_x.third < _y.third));
 
53
}
 
54
 
 
55
template<class _T1, class _T2, class _T3>
 
56
inline bool operator!=(
 
57
        const triple<_T1, _T2, _T3>& _x,
 
58
        const triple<_T1, _T2, _T3>& _y)
 
59
{
 
60
        return !(_x == _y);
 
61
}
 
62
 
 
63
template<class _T1, class _T2, class _T3>
 
64
inline bool operator>(
 
65
        const triple<_T1, _T2, _T3>& _x,
 
66
        const triple<_T1, _T2, _T3>& _y)
 
67
{
 
68
        return _y < _x;
 
69
}
 
70
 
 
71
template<class _T1, class _T2, class _T3>
 
72
inline bool operator<=(
 
73
        const triple<_T1, _T2, _T3>& _x,
 
74
        const triple<_T1, _T2, _T3>& _y)
 
75
{
 
76
        return !(_y < _x);
 
77
}
 
78
 
 
79
template<class _T1, class _T2, class _T3>
 
80
inline bool operator>=(
 
81
        const triple<_T1, _T2, _T3>& _x,
 
82
        const triple<_T1, _T2, _T3>& _y)
 
83
{
 
84
        return !(_x < _y);
 
85
}
 
86
 
 
87
template<class _T1, class _T2, class _T3>
 
88
inline triple<_T1, _T2, _T3>
 
89
make_triple(_T1 _x, _T2 _y, _T3 _z)
 
90
{
 
91
        return triple<_T1, _T2, _T3>(_x, _y, _z);
 
92
}
 
93
 
 
94
} /* namespace xqp */
 
95
#endif /* XQP_TRIPLE_H */
 
96