Carna  Version 3.3.2
Span.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 - 2015 Leonid Kostrykin
3  *
4  * Chair of Medical Engineering (mediTEC)
5  * RWTH Aachen University
6  * Pauwelsstr. 20
7  * 52074 Aachen
8  * Germany
9  *
10  */
11 
12 #ifndef SPAN_H_6014714286
13 #define SPAN_H_6014714286
14 
19 #include <Carna/base/math.h>
20 
21 namespace Carna
22 {
23 
24 namespace base
25 {
26 
27 namespace math
28 {
29 
30 
31 
32 // ----------------------------------------------------------------------------------
33 // Span
34 // ----------------------------------------------------------------------------------
35 
42 template< typename T >
43 class Span
44 {
45 
46 public:
47 
51  Span();
52 
55  Span( const T& first, const T& last );
56 
60  Span( const Span< T >& other );
61 
65  bool operator==( const Span< T >& other ) const;
66 
73  bool operator<( const Span< T >& other ) const;
74 
78  T first;
79 
83  T last;
84 
85 }; // Span
86 
87 
88 template< typename T >
90  : first( T() ), last( T() )
91 {
92 }
93 
94 
95 template< typename T >
96 Span< T >::Span( const T& first, const T& last )
97  : first( first ), last( last )
98 {
99 }
100 
101 
102 template< typename T >
103 Span< T >::Span( const Span< T >& other )
104  : first( other.first )
105  , last( other.last )
106 {
107 }
108 
109 
110 template< typename T >
111 bool Span< T >::operator==( const Span< T >& other ) const
112 {
113  return isEqual( first, other.first ) && isEqual( last, other.last );
114 }
115 
116 
117 template< typename T >
118 bool Span< T >::operator<( const Span< T >& other ) const
119 {
120  return first != other.first ? first < other.first : last < other.last;
121 }
122 
123 
124 
125 } // namespace Carna :: base :: math
126 
127 } // namespace Carna :: base
128 
129 } // namespace Carna
130 
131 #endif // SPAN_H_6014714286
Defines Carna::base::math namespace and CARNA_FOR_VECTOR3UI.
Span()
Instantiates.
Definition: Span.h:89
T first
Holds the of .
Definition: Span.h:78
bool operator==(const Span< T > &other) const
Returns whether this span equals other.
Definition: Span.h:111
Defines an interval with T.
Definition: Span.h:43
T last
Holds the of .
Definition: Span.h:83
bool isEqual(const InputType &x, const InputType &y)
Tells whether two objects are equal respectively to epsilon.
Definition: math.h:174