Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnTriplet.h
1 /*****************************************************************************
2 ** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT
3 ** Distributed under the terms of the BSD license (see the LICENSE file)
4 ** Copyright (c) 2007-2015, Stephen Gould
5 ** All rights reserved.
6 **
7 ******************************************************************************
8 ** FILENAME: drwnTriplet.h
9 ** AUTHOR(S): Stephen Gould <stephen.gould@anu.edu.au>
10 **
11 *****************************************************************************/
12 
13 #pragma once
14 
15 #include <ctime>
16 #include <vector>
17 #include <map>
18 #include <string>
19 #include <iostream>
20 
21 // drwnTriplet class --------------------------------------------------------
31 
32 template<class T, class U = T, class V = T>
33 class drwnTriplet {
34  public:
35  T first;
36  U second;
37  V third;
38 
39  public:
40  inline drwnTriplet() { }
41  inline drwnTriplet(const T& i, const U& j, const V& k) :
42  first(i), second(j), third(k) { }
43  inline drwnTriplet(const drwnTriplet<T,U,V>& t) :
44  first(t.first), second(t.second), third(t.third) { }
45  inline ~drwnTriplet() { }
46 
47  // operators
48  inline drwnTriplet<T,U,V>& operator=(const drwnTriplet<T,U,V>& t);
49  inline bool operator==(const drwnTriplet<T,U,V>& t) const;
50  inline bool operator<(const drwnTriplet<T,U,V>& t) const;
51 };
52 
53 // implementation -----------------------------------------------------------
54 
55 template<class T, class U, class V>
57  first = t.first;
58  second = t.second;
59  third = t.third;
60 
61  return *this;
62 }
63 
64 template<class T, class U, class V>
65 inline bool drwnTriplet<T,U,V>::operator==(const drwnTriplet<T,U,V>& t) const {
66  return ((t.first == first) && (t.second == second) && (t.third == third));
67 }
68 
69 template<class T, class U, class V>
70 inline bool drwnTriplet<T,U,V>::operator<(const drwnTriplet<T,U,V>& t) const {
71  return ((first < t.first) || (second < t.second) || (third < t.third));
72 }
U second
second object in the triplet
Definition: drwnTriplet.h:36
V third
third object in thr triplet
Definition: drwnTriplet.h:37
T first
first object in the triplet
Definition: drwnTriplet.h:35
Basic datatype for holding three objects of arbitrary type. Similar to the STL pair<> class...
Definition: drwnTriplet.h:33