Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
keyvaluepair.h
Go to the documentation of this file.
1
#pragma once
2
//------------------------------------------------------------------------------
13
#include "
core/types.h
"
14
15
//------------------------------------------------------------------------------
16
namespace
Util
17
{
18
template
<
class
KEYTYPE,
class
VALUETYPE>
class
KeyValuePair
19
{
20
public
:
22
KeyValuePair
();
24
KeyValuePair
(
const
KEYTYPE& k,
const
VALUETYPE& v);
26
explicit
KeyValuePair
(
const
KEYTYPE& k);
28
KeyValuePair
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs);
30
KeyValuePair
(
KeyValuePair<KEYTYPE, VALUETYPE>
&& rhs)
noexcept
;
32
void
operator=
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs);
34
void
operator=
(
KeyValuePair<KEYTYPE, VALUETYPE>
&& rhs)
noexcept
;
36
bool
operator==
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
const
;
38
bool
operator!=
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
const
;
40
bool
operator>
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
const
;
42
bool
operator>=
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
const
;
44
bool
operator<
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
const
;
46
bool
operator<=
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
const
;
48
bool
operator==
(
const
KEYTYPE& rhs)
const
;
50
bool
operator!=
(
const
KEYTYPE& rhs)
const
;
52
bool
operator>
(
const
KEYTYPE& rhs)
const
;
54
bool
operator>=
(
const
KEYTYPE& rhs)
const
;
56
bool
operator<
(
const
KEYTYPE& rhs)
const
;
58
bool
operator<=
(
const
KEYTYPE& rhs)
const
;
60
VALUETYPE&
Value
();
62
const
KEYTYPE&
Key
()
const
;
64
const
VALUETYPE&
Value
()
const
;
65
66
KEYTYPE
keyData
= KEYTYPE();
67
VALUETYPE
valueData
= VALUETYPE();
68
};
69
70
//------------------------------------------------------------------------------
73
template
<
class
KEYTYPE,
class
VALUETYPE>
74
KeyValuePair<KEYTYPE, VALUETYPE>::KeyValuePair
()
75
{
76
// empty
77
}
78
79
//------------------------------------------------------------------------------
82
template
<
class
KEYTYPE,
class
VALUETYPE>
83
KeyValuePair<KEYTYPE, VALUETYPE>::KeyValuePair
(
const
KEYTYPE& k,
const
VALUETYPE& v) :
84
keyData
(k),
85
valueData
(v)
86
{
87
// empty
88
}
89
90
//------------------------------------------------------------------------------
95
template
<
class
KEYTYPE,
class
VALUETYPE>
96
KeyValuePair<KEYTYPE, VALUETYPE>::KeyValuePair
(
const
KEYTYPE& k) :
97
keyData
(k)
98
{
99
// empty
100
}
101
102
//------------------------------------------------------------------------------
105
template
<
class
KEYTYPE,
class
VALUETYPE>
106
KeyValuePair<KEYTYPE, VALUETYPE>::KeyValuePair
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs) :
107
keyData
(rhs.
keyData
),
108
valueData
(rhs.
valueData
)
109
{
110
// empty
111
}
112
113
//------------------------------------------------------------------------------
116
template
<
class
KEYTYPE,
class
VALUETYPE>
117
KeyValuePair<KEYTYPE, VALUETYPE>::KeyValuePair
(
KeyValuePair<KEYTYPE, VALUETYPE>
&& rhs)
noexcept
:
118
keyData
(std::move(rhs.keyData)),
119
valueData
(std::move(rhs.valueData))
120
{
121
// empty
122
}
123
124
//------------------------------------------------------------------------------
127
template
<
class
KEYTYPE,
class
VALUETYPE>
128
void
129
KeyValuePair<KEYTYPE, VALUETYPE>::operator=
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
130
{
131
this->
keyData
= rhs.
keyData
;
132
this->
valueData
= rhs.
valueData
;
133
}
134
135
//------------------------------------------------------------------------------
138
template
<
class
KEYTYPE,
class
VALUETYPE>
139
void
140
KeyValuePair<KEYTYPE, VALUETYPE>::operator=
(
KeyValuePair<KEYTYPE, VALUETYPE>
&& rhs)
noexcept
141
{
142
this->
keyData
= std::move(rhs.keyData);
143
this->
valueData
= std::move(rhs.valueData);
144
}
145
146
//------------------------------------------------------------------------------
149
template
<
class
KEYTYPE,
class
VALUETYPE>
150
bool
151
KeyValuePair<KEYTYPE, VALUETYPE>::operator==
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
const
152
{
153
return
(this->
keyData
== rhs.
keyData
);
154
}
155
156
//------------------------------------------------------------------------------
159
template
<
class
KEYTYPE,
class
VALUETYPE>
160
bool
161
KeyValuePair<KEYTYPE, VALUETYPE>::operator!=
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
const
162
{
163
return
(this->
keyData
!= rhs.
keyData
);
164
}
165
166
//------------------------------------------------------------------------------
169
template
<
class
KEYTYPE,
class
VALUETYPE>
170
bool
171
KeyValuePair<KEYTYPE, VALUETYPE>::operator>
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
const
172
{
173
return
(this->
keyData
> rhs.
keyData
);
174
}
175
176
//------------------------------------------------------------------------------
179
template
<
class
KEYTYPE,
class
VALUETYPE>
180
bool
181
KeyValuePair<KEYTYPE, VALUETYPE>::operator>=
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
const
182
{
183
return
(this->
keyData
>= rhs.
keyData
);
184
}
185
186
//------------------------------------------------------------------------------
189
template
<
class
KEYTYPE,
class
VALUETYPE>
190
bool
191
KeyValuePair<KEYTYPE, VALUETYPE>::operator<
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
const
192
{
193
return
(this->
keyData
< rhs.
keyData
);
194
}
195
196
//------------------------------------------------------------------------------
199
template
<
class
KEYTYPE,
class
VALUETYPE>
200
bool
201
KeyValuePair<KEYTYPE, VALUETYPE>::operator<=
(
const
KeyValuePair<KEYTYPE, VALUETYPE>
& rhs)
const
202
{
203
return
(this->
keyData
<= rhs.
keyData
);
204
}
205
206
//------------------------------------------------------------------------------
209
template
<
class
KEYTYPE,
class
VALUETYPE>
210
bool
211
KeyValuePair<KEYTYPE, VALUETYPE>::operator==
(
const
KEYTYPE& rhs)
const
212
{
213
return
(this->
keyData
== rhs);
214
}
215
216
//------------------------------------------------------------------------------
219
template
<
class
KEYTYPE,
class
VALUETYPE>
220
bool
221
KeyValuePair<KEYTYPE, VALUETYPE>::operator!=
(
const
KEYTYPE& rhs)
const
222
{
223
return
(this->
keyData
!= rhs);
224
}
225
226
//------------------------------------------------------------------------------
229
template
<
class
KEYTYPE,
class
VALUETYPE>
230
bool
231
KeyValuePair<KEYTYPE, VALUETYPE>::operator>
(
const
KEYTYPE& rhs)
const
232
{
233
return
(this->
keyData
> rhs);
234
}
235
236
//------------------------------------------------------------------------------
239
template
<
class
KEYTYPE,
class
VALUETYPE>
240
bool
241
KeyValuePair<KEYTYPE, VALUETYPE>::operator>=
(
const
KEYTYPE& rhs)
const
242
{
243
return
(this->
keyData
>= rhs);
244
}
245
246
//------------------------------------------------------------------------------
249
template
<
class
KEYTYPE,
class
VALUETYPE>
250
bool
251
KeyValuePair<KEYTYPE, VALUETYPE>::operator<
(
const
KEYTYPE& rhs)
const
252
{
253
return
(this->
keyData
< rhs);
254
}
255
256
//------------------------------------------------------------------------------
259
template
<
class
KEYTYPE,
class
VALUETYPE>
260
bool
261
KeyValuePair<KEYTYPE, VALUETYPE>::operator<=
(
const
KEYTYPE& rhs)
const
262
{
263
return
(this->
keyData
<= rhs);
264
}
265
266
267
//------------------------------------------------------------------------------
270
template
<
class
KEYTYPE,
class
VALUETYPE>
271
VALUETYPE&
272
KeyValuePair<KEYTYPE, VALUETYPE>::Value
()
273
{
274
return
this->
valueData
;
275
}
276
277
//------------------------------------------------------------------------------
280
template
<
class
KEYTYPE,
class
VALUETYPE>
281
const
KEYTYPE&
282
KeyValuePair<KEYTYPE, VALUETYPE>::Key
()
const
283
{
284
return
this->
keyData
;
285
}
286
287
//------------------------------------------------------------------------------
290
template
<
class
KEYTYPE,
class
VALUETYPE>
291
const
VALUETYPE&
292
KeyValuePair<KEYTYPE, VALUETYPE>::Value
()
const
293
{
294
return
this->
valueData
;
295
}
296
297
}
// namespace Util
298
//------------------------------------------------------------------------------
Util::KeyValuePair::Key
const KEYTYPE & Key() const
read access to key
Definition
keyvaluepair.h:282
Util::KeyValuePair::keyData
KEYTYPE keyData
Definition
keyvaluepair.h:66
Util::KeyValuePair::operator>=
bool operator>=(const KeyValuePair< KEYTYPE, VALUETYPE > &rhs) const
greater-or-equal operator
Definition
keyvaluepair.h:181
Util::KeyValuePair::operator==
bool operator==(const KeyValuePair< KEYTYPE, VALUETYPE > &rhs) const
equality operator
Definition
keyvaluepair.h:151
Util::KeyValuePair::valueData
VALUETYPE valueData
Definition
keyvaluepair.h:67
Util::KeyValuePair::operator=
void operator=(const KeyValuePair< KEYTYPE, VALUETYPE > &rhs)
assignment operator
Definition
keyvaluepair.h:129
Util::KeyValuePair::operator<=
bool operator<=(const KeyValuePair< KEYTYPE, VALUETYPE > &rhs) const
lesser-or-equal operator
Definition
keyvaluepair.h:201
Util::KeyValuePair::operator!=
bool operator!=(const KeyValuePair< KEYTYPE, VALUETYPE > &rhs) const
inequality operator
Definition
keyvaluepair.h:161
Util::KeyValuePair::KeyValuePair
KeyValuePair()
default constructor
Definition
keyvaluepair.h:74
Util::KeyValuePair::operator>
bool operator>(const KeyValuePair< KEYTYPE, VALUETYPE > &rhs) const
greater operator
Definition
keyvaluepair.h:171
Util::KeyValuePair::Value
VALUETYPE & Value()
read/write access to value
Definition
keyvaluepair.h:272
Util::KeyValuePair::operator<
bool operator<(const KeyValuePair< KEYTYPE, VALUETYPE > &rhs) const
lesser operator
Definition
keyvaluepair.h:191
Util
A quad tree designed to return regions of free 2D space.
Definition
String.cs:6
types.h
code
foundation
util
keyvaluepair.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.