Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JTOOLS::JMultiKey< N, JKey_t > Class Template Reference

Multidimensional key. More...

#include <JMultiKey.hh>

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

Public Types

typedef JKey_t key_type
 
typedef JMultiKey< N-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< N, JKey_t >::argument_type key)
 Copy constructor.
 
bool less (const JMultiKey< N, JKey_t > &key) const
 Less than method.
 
double getLengthSquared () const
 Get length squared.
 
double getLength () const
 Get length.
 
JMultiKey< N-1, JKey_t > front () const
 Get frontend key.
 
key_type back () const
 Get backend key.
 

Friends

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

Detailed Description

template<unsigned int N, class JKey_t>
class JTOOLS::JMultiKey< N, JKey_t >

Multidimensional key.

This class reproduces the key of a multidimensional map. The individual data members can be accessed as, e.g:

          JMultiKey<3, key_type>  key;

          key[[.second].second].first;

Definition at line 66 of file JMultiKey.hh.

Member Typedef Documentation

◆ key_type

template<unsigned int N, class JKey_t >
JKey_t JTOOLS::JMultiKey< N, JKey_t >::key_type

Definition at line 72 of file JMultiKey.hh.

◆ mapped_type

template<unsigned int N, class JKey_t >
JMultiKey<N-1, JKey_t> JTOOLS::JMultiKey< N, JKey_t >::mapped_type

Definition at line 73 of file JMultiKey.hh.

◆ pair_type

template<unsigned int N, class JKey_t >
std::pair<key_type, mapped_type> JTOOLS::JMultiKey< N, JKey_t >::pair_type

Definition at line 74 of file JMultiKey.hh.

Constructor & Destructor Documentation

◆ JMultiKey() [1/4]

template<unsigned int N, class JKey_t >
JTOOLS::JMultiKey< N, JKey_t >::JMultiKey ( )
inline

Default constructor.

Definition at line 80 of file JMultiKey.hh.

80 :
81 pair_type()
82 {}
std::pair< key_type, mapped_type > pair_type
Definition JMultiKey.hh:74

◆ JMultiKey() [2/4]

template<unsigned int N, class JKey_t >
JTOOLS::JMultiKey< N, 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 keys.

Parameters
__firstprimary keys
__secondsecondary key

Definition at line 92 of file JMultiKey.hh.

93 :
94 pair_type(__first.first, mapped_type(__first.second, __second))
95 {}
JMultiKey< N-1, JKey_t > mapped_type
Definition JMultiKey.hh:73

◆ JMultiKey() [3/4]

template<unsigned int N, class JKey_t >
JTOOLS::JMultiKey< N, 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 keys.

Parameters
__firstprimary key
__secondsecondary keys

Definition at line 105 of file JMultiKey.hh.

106 :
107 pair_type(__first, __second)
108 {}

◆ JMultiKey() [4/4]

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

Copy constructor.

Parameters
keykey

Definition at line 116 of file JMultiKey.hh.

116 :
117 pair_type(key.first, key.second)
118 {}

Member Function Documentation

◆ less()

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

Less than method.

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

Definition at line 127 of file JMultiKey.hh.

128 {
129 if (this->first == key.first)
130 return this->second.less(key.second);
131 else
132 return this->first < key.first;
133 }

◆ getLengthSquared()

template<unsigned int N, class JKey_t >
double JTOOLS::JMultiKey< N, JKey_t >::getLengthSquared ( ) const
inline

Get length squared.

Returns
square of length

Definition at line 141 of file JMultiKey.hh.

142 {
143 return this->first*this->first + this->second.getLengthSquared();
144 }

◆ getLength()

template<unsigned int N, class JKey_t >
double JTOOLS::JMultiKey< N, JKey_t >::getLength ( ) const
inline

Get length.

Returns
length

Definition at line 152 of file JMultiKey.hh.

153 {
154 return sqrt(this->getLengthSquared());
155 }
double getLengthSquared() const
Get length squared.
Definition JMultiKey.hh:141

◆ front()

template<unsigned int N, class JKey_t >
JMultiKey< N-1, JKey_t > JTOOLS::JMultiKey< N, JKey_t >::front ( ) const
inline

Get frontend key.

Returns
frontend key

Definition at line 163 of file JMultiKey.hh.

164 {
165 return JMultiKey<N-1, JKey_t>(this->first, this->second.front());
166 }
JMultiKey()
Default constructor.
Definition JMultiKey.hh:80

◆ back()

template<unsigned int N, class JKey_t >
key_type JTOOLS::JMultiKey< N, JKey_t >::back ( ) const
inline

Get backend key.

Returns
backend key

Definition at line 174 of file JMultiKey.hh.

175 {
176 return this->second.back();
177 }

Friends And Related Symbol Documentation

◆ operator>>

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

Read key from input.

Parameters
ininput stream
keykey
Returns
input stream

Definition at line 187 of file JMultiKey.hh.

188 {
189 in >> key.first;
190 in >> key.second;
191
192 return in;
193 }

◆ operator<<

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

Write key to output.

Parameters
outoutput stream
keykey
Returns
output stream

Definition at line 203 of file JMultiKey.hh.

204 {
205 const JFormat format(out, getFormat< JMultiKey<N, JKey_t> >(JFormat_t(9, 3, std::ios::fixed | std::ios::showpos)));
206
207 out << format << key.first;
208 out << ' ';
209 out << key.second;
210
211 return out;
212 }
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: