Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Friends | List of all members
JTOOLS::JMultiKey< N, JKey_t > Class Template Reference

Forward declaration of template JMultiKey class. More...

#include <JMultiKey.hh>

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

Public Types

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

Public Member Functions

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

Friends

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

Detailed Description

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

Forward declaration of template JMultiKey class.

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 29 of file JMultiKey.hh.

Member Typedef Documentation

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

Definition at line 67 of file JMultiKey.hh.

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

Definition at line 68 of file JMultiKey.hh.

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

Definition at line 69 of file JMultiKey.hh.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 75 of file JMultiKey.hh.

75  :
76  pair()
77  {}
std::pair< key_type, mapped_type > pair
Definition: JMultiKey.hh:69
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 87 of file JMultiKey.hh.

88  :
89  pair(__first.first, mapped_type(__first.second, __second))
90  {}
std::pair< key_type, mapped_type > pair
Definition: JMultiKey.hh:69
JMultiKey< N-1, JKey_t > mapped_type
Definition: JMultiKey.hh:68
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 100 of file JMultiKey.hh.

101  :
102  pair(__first, __second)
103  {}
std::pair< key_type, mapped_type > pair
Definition: JMultiKey.hh:69
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 111 of file JMultiKey.hh.

111  :
112  pair(key.first, key.second)
113  {}
std::pair< key_type, mapped_type > pair
Definition: JMultiKey.hh:69

Member Function Documentation

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 122 of file JMultiKey.hh.

123  {
124  if (this->first == key.first)
125  return this->second.less(key.second);
126  else
127  return this->first < key.first;
128  }
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 136 of file JMultiKey.hh.

137  {
138  return this->first*this->first + this->second.getLengthSquared();
139  }
template<unsigned int N, class JKey_t>
double JTOOLS::JMultiKey< N, JKey_t >::getLength ( ) const
inline

Get length.

Returns
length

Definition at line 147 of file JMultiKey.hh.

148  {
149  return sqrt(this->getLengthSquared());
150  }
double getLengthSquared() const
Get length squared.
Definition: JMultiKey.hh:136
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 158 of file JMultiKey.hh.

159  {
160  return JMultiKey<N-1, JKey_t>(this->first, this->second.front());
161  }
Forward declaration of template JMultiKey class.
Definition: JMultiKey.hh:29
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 169 of file JMultiKey.hh.

170  {
171  return this->second.back();
172  }

Friends And Related Function Documentation

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 182 of file JMultiKey.hh.

183  {
184  in >> key.first;
185  in >> key.second;
186 
187  return in;
188  }
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 198 of file JMultiKey.hh.

199  {
200  out << key.first;
201  out << ' ';
202  out << key.second;
203 
204  return out;
205  }

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