Jpp  18.3.0-rc.1
the software that should make you happy
 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

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_type
pair_type
 

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 >

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 34 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 72 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 73 of file JMultiKey.hh.

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

Definition at line 74 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 80 of file JMultiKey.hh.

80  :
81  pair_type()
82  {}
std::pair< key_type, mapped_type > pair_type
Definition: JMultiKey.hh:74
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  {}
std::pair< key_type, mapped_type > pair_type
Definition: JMultiKey.hh:74
JMultiKey< N-1, JKey_t > mapped_type
Definition: JMultiKey.hh:73
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  {}
std::pair< key_type, mapped_type > pair_type
Definition: JMultiKey.hh:74
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  {}
std::pair< key_type, mapped_type > pair_type
Definition: JMultiKey.hh:74

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 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  }
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
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  }
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
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
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  }
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
Multidimensional key.
Definition: JMultiKey.hh:34
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:40
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 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 187 of file JMultiKey.hh.

188  {
189  in >> key.first;
190  in >> key.second;
191 
192  return in;
193  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
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
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:634
Multidimensional key.
Definition: JMultiKey.hh:34
Data structure for format specifications.
Definition: JManip.hh:524

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