Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JTOOLS::JMultiKey< 2, JKey_t > Class Template Reference

Two-dimensional key. More...

#include <JMultiKey.hh>

Inheritance diagram for JTOOLS::JMultiKey< 2, JKey_t >:
std::pair< JKey_t, JMultiKey< 1, JKey_t > > JLANG::JComparable< JFirst_t, JSecond_t >

Public Types

typedef JKey_t key_type
 
typedef JMultiKey< 1, JKey_t > mapped_type
 
typedef std::pair< key_type, mapped_typepair_type
 

Public Member Functions

 JMultiKey ()
 Default constructor.
 
 JMultiKey (typename JClass< mapped_type >::argument_type __first, typename JClass< key_type > ::argument_type __second)
 Constructor.
 
 JMultiKey (typename JClass< key_type > ::argument_type __first, typename JClass< mapped_type >::argument_type __second)
 Constructor.
 
 JMultiKey (typename JArgument< 2, JKey_t >::argument_type key)
 Copy constructor.
 
bool less (const JMultiKey< 2, JKey_t > &key) const
 Less than method.
 
double getLengthSquared () const
 Get length squared.
 
double getLength () const
 Get length.
 
JMultiKey< 1, JKey_t > front () const
 Get frontend key.
 
key_type back () const
 Get backend key.
 

Friends

std::istream & operator>> (std::istream &in, JMultiKey< 2, JKey_t > &key)
 Read key from input.
 
std::ostream & operator<< (std::ostream &out, const JMultiKey< 2, JKey_t > &key)
 Write key to output.
 

Detailed Description

template<class JKey_t>
class JTOOLS::JMultiKey< 2, JKey_t >

Two-dimensional key.

Definition at line 220 of file JMultiKey.hh.

Member Typedef Documentation

◆ key_type

template<class JKey_t >
JKey_t JTOOLS::JMultiKey< 2, JKey_t >::key_type

Definition at line 226 of file JMultiKey.hh.

◆ mapped_type

template<class JKey_t >
JMultiKey<1, JKey_t> JTOOLS::JMultiKey< 2, JKey_t >::mapped_type

Definition at line 227 of file JMultiKey.hh.

◆ pair_type

template<class JKey_t >
std::pair<key_type, mapped_type> JTOOLS::JMultiKey< 2, JKey_t >::pair_type

Definition at line 228 of file JMultiKey.hh.

Constructor & Destructor Documentation

◆ JMultiKey() [1/4]

template<class JKey_t >
JTOOLS::JMultiKey< 2, JKey_t >::JMultiKey ( )
inline

Default constructor.

Definition at line 234 of file JMultiKey.hh.

234 :
235 pair_type()
236 {}
std::pair< key_type, mapped_type > pair_type
Definition JMultiKey.hh:228

◆ JMultiKey() [2/4]

template<class JKey_t >
JTOOLS::JMultiKey< 2, JKey_t >::JMultiKey ( typename JClass< mapped_type >::argument_type __first,
typename JClass< key_type > ::argument_type __second )
inline

Constructor.

The secondary key is appended to the end of the primary key.

Parameters
__firstprimary key
__secondsecondary key

Definition at line 246 of file JMultiKey.hh.

247 :
248 pair_type(__first.first, __second)
249 {}

◆ JMultiKey() [3/4]

template<class JKey_t >
JTOOLS::JMultiKey< 2, JKey_t >::JMultiKey ( typename JClass< key_type > ::argument_type __first,
typename JClass< mapped_type >::argument_type __second )
inline

Constructor.

The primary key is inserted at the start of the secondary key.

Parameters
__firstprimary key
__secondsecondary key

Definition at line 259 of file JMultiKey.hh.

260 :
261 pair_type(__first, __second.first)
262 {}

◆ JMultiKey() [4/4]

template<class JKey_t >
JTOOLS::JMultiKey< 2, JKey_t >::JMultiKey ( typename JArgument< 2, JKey_t >::argument_type key)
inline

Copy constructor.

Parameters
keykey

Definition at line 270 of file JMultiKey.hh.

270 :
271 pair_type(key.first, key.second)
272 {}

Member Function Documentation

◆ less()

template<class JKey_t >
bool JTOOLS::JMultiKey< 2, JKey_t >::less ( const JMultiKey< 2, JKey_t > & key) const
inline

Less than method.

Parameters
keykey
Returns
true if this key less than given key; else false

Definition at line 281 of file JMultiKey.hh.

282 {
283 if (this->first == key.first)
284 return this->second.less(key.second);
285 else
286 return this->first < key.first;
287 }

◆ getLengthSquared()

template<class JKey_t >
double JTOOLS::JMultiKey< 2, JKey_t >::getLengthSquared ( ) const
inline

Get length squared.

Returns
square of length

Definition at line 295 of file JMultiKey.hh.

296 {
297 return this->first*this->first + this->second.getLengthSquared();
298 }

◆ getLength()

template<class JKey_t >
double JTOOLS::JMultiKey< 2, JKey_t >::getLength ( ) const
inline

Get length.

Returns
length

Definition at line 306 of file JMultiKey.hh.

307 {
308 return sqrt(this->getLengthSquared());
309 }
double getLengthSquared() const
Get length squared.
Definition JMultiKey.hh:295

◆ front()

template<class JKey_t >
JMultiKey< 1, JKey_t > JTOOLS::JMultiKey< 2, JKey_t >::front ( ) const
inline

Get frontend key.

Returns
frontend key

Definition at line 317 of file JMultiKey.hh.

318 {
319 return JMultiKey<1, JKey_t>(this->first);
320 }

◆ back()

template<class JKey_t >
key_type JTOOLS::JMultiKey< 2, JKey_t >::back ( ) const
inline

Get backend key.

Returns
backend key

Definition at line 328 of file JMultiKey.hh.

329 {
330 return this->second.back();
331 }

Friends And Related Symbol Documentation

◆ operator>>

template<class JKey_t >
std::istream & operator>> ( std::istream & in,
JMultiKey< 2, JKey_t > & key )
friend

Read key from input.

Parameters
ininput stream
keykey
Returns
input stream

Definition at line 341 of file JMultiKey.hh.

342 {
343 in >> key.first;
344 in >> key.second;
345
346 return in;
347 }

◆ operator<<

template<class JKey_t >
std::ostream & operator<< ( std::ostream & out,
const JMultiKey< 2, JKey_t > & key )
friend

Write key to output.

Parameters
outoutput stream
keykey
Returns
output stream

Definition at line 357 of file JMultiKey.hh.

358 {
359 const JFormat format(out, getFormat< JMultiKey<2, JKey_t> >(JFormat_t(9, 3, std::ios::fixed | std::ios::showpos)));
360
361 out << format << key.first;
362 out << ' ';
363 out << key.second;
364
365 return out;
366 }
JFormat_t & getFormat()
Get format for given type.
Definition JManip.hh:682
Data structure for format specifications.
Definition JManip.hh:524
Auxiliary class to temporarily define format specifications.
Definition JManip.hh:636

The documentation for this class was generated from the following file: