File: triple.h

package info (click to toggle)
neartree 5.1.1+dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,380 kB
  • sloc: cpp: 12,313; ansic: 5,956; makefile: 495
file content (87 lines) | stat: -rw-r--r-- 4,169 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 *  triple.h
 *  
 *
 *  Created by Herbert J. Bernstein on 10/26/10.
 *  Copyright 2010 Herbert J. Bernstein
 *
 */
 
/**********************************************************************
 *                                                                    *
 * YOU MAY REDISTRIBUTE THE CVector API UNDER THE TERMS OF THE LGPL   *
 *                                                                    *
 **********************************************************************/

/************************* LGPL NOTICES *******************************
 *                                                                    *
 * This library is free software; you can redistribute it and/or      *
 * modify it under the terms of the GNU Lesser General Public         *
 * License as published by the Free Software Foundation; either       *
 * version 2.1 of the License, or (at your option) any later version. *
 *                                                                    *
 * This library is distributed in the hope that it will be useful,    *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  *
 * Lesser General Public License for more details.                    *
 *                                                                    *
 * You should have received a copy of the GNU Lesser General Public   *
 * License along with this library; if not, write to the Free         *
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,    *
 * MA  02110-1301  USA                                                *
 *                                                                    *
 **********************************************************************/

/************************* PAIR.H NOTICE ******************************
 * triple.h was derived from pair.h                                   *
 *  which was subject to the following notice:                        *
 *                                                                    *
 * Copyright (c) 1994                                                 *
 * Hewlett-Packard Company                                            *
 *                                                                    *
 * Permission to use, copy, modify, distribute and sell this software *
 * and its documentation for any purpose is hereby granted without    *
 * fee, provided that the above copyright notice appear in all copies *
 * and that both that copyright notice and this permission notice     *
 * appear in supporting documentation.  Hewlett-Packard Company makes *
 * no representations about the suitability of this software for any  *
 * purpose.  It is provided "as is" without express or implied        *
 * warranty.                                                          *
 *                                                                    *
 **********************************************************************/

#ifndef TRIPLE_H
#define TRIPLE_H

template <class TR1, class TR2, class TR3>
class triple {
private:
    TR1 m_first;
    TR2 m_second;
    TR3 m_third;
public:
    triple() : m_first(TR1()), m_second(TR2()), m_third(TR3()) {}
    triple(const TR1& first, const TR2& second, const TR3& third ) : m_first(first), m_second(second), m_third(third) {}
    inline TR1 GetFirst( void ) const  { return m_first;  }  
    inline TR2 GetSecond( void ) const { return m_second; }  
    inline TR3 GetThird( void ) const  { return m_third;  }  

inline bool operator==(const triple<TR1, TR2, TR3>& rhs) { 
    return m_first == rhs.GetFirst() && m_second == rhs.m_second && m_third == rhs.m_third; 
}

inline bool operator<(const triple<TR1, TR2, TR3>& rhs) { 
    return m_first < rhs.GetFirst() 
      || (m_first == rhs.GetFirst() && m_second < rhs.GetSecond)
      || (m_first == rhs.GetFirst() && m_second < rhs.GetSecond && m_third < rhs.GetThird); 
}

};

template <class TR1, class TR2, class TR3>
inline triple<TR1, TR2, TR3> make_triple(const TR1& first, const TR2& second, const TR3& third) {
    return triple<TR1, TR2, TR3>(first, second, third);
}


#endif