ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
LookUpTable< T, C > Class Template Reference

#include <LookUpTable.h>

Collaboration diagram for LookUpTable< T, C >:

Public Types

typedef T val_type
 
typedef std::vector< val_typevec_type
 
typedef std::pair< val_type, val_typepair_type
 
typedef vec_type::iterator vec_type_it
 
typedef vec_type::const_iterator vec_type_cit
 

Public Member Functions

 LookUpTable ()=default
 
 ~LookUpTable ()=default
 
bool empty () const
 
void setData (const vec_type &data)
 
const vec_typegetData () const
 
vec_type_it begin ()
 
vec_type_it end ()
 
vec_type_cit begin () const
 
vec_type_cit end () const
 
vec_type_cit lowerBound (const val_type &val)
 
pair_type find (const val_type &val) const
 
template<class CC >
pair_type find (const val_type &val, const CC &c) const
 

Private Attributes

vec_type m_data
 

Detailed Description

template<class T, class C = std::less<T>>
class LookUpTable< T, C >

Generic lookup table. Uses comparison function objects or the < operator to sort and look up values in the table.

Definition at line 21 of file LookUpTable.h.

Member Typedef Documentation

◆ pair_type

template<class T , class C = std::less<T>>
typedef std::pair<val_type, val_type> LookUpTable< T, C >::pair_type

Definition at line 25 of file LookUpTable.h.

◆ val_type

template<class T , class C = std::less<T>>
typedef T LookUpTable< T, C >::val_type

Definition at line 23 of file LookUpTable.h.

◆ vec_type

template<class T , class C = std::less<T>>
typedef std::vector<val_type> LookUpTable< T, C >::vec_type

Definition at line 24 of file LookUpTable.h.

◆ vec_type_cit

template<class T , class C = std::less<T>>
typedef vec_type::const_iterator LookUpTable< T, C >::vec_type_cit

Definition at line 28 of file LookUpTable.h.

◆ vec_type_it

template<class T , class C = std::less<T>>
typedef vec_type::iterator LookUpTable< T, C >::vec_type_it

Definition at line 27 of file LookUpTable.h.

Constructor & Destructor Documentation

◆ LookUpTable()

template<class T , class C = std::less<T>>
LookUpTable< T, C >::LookUpTable ( )
default

◆ ~LookUpTable()

template<class T , class C = std::less<T>>
LookUpTable< T, C >::~LookUpTable ( )
default

Member Function Documentation

◆ begin() [1/2]

template<class T , class C = std::less<T>>
vec_type_it LookUpTable< T, C >::begin ( )
inline

Definition at line 38 of file LookUpTable.h.

38 { return m_data.begin(); }

◆ begin() [2/2]

template<class T , class C = std::less<T>>
vec_type_cit LookUpTable< T, C >::begin ( ) const
inline

Definition at line 40 of file LookUpTable.h.

40 { return m_data.begin(); }

◆ empty()

template<class T , class C = std::less<T>>
bool LookUpTable< T, C >::empty ( ) const
inline

Definition at line 33 of file LookUpTable.h.

33 { return m_data.empty(); }

◆ end() [1/2]

template<class T , class C = std::less<T>>
vec_type_it LookUpTable< T, C >::end ( )
inline

Definition at line 39 of file LookUpTable.h.

39 { return m_data.end(); }

◆ end() [2/2]

template<class T , class C = std::less<T>>
vec_type_cit LookUpTable< T, C >::end ( ) const
inline

Definition at line 41 of file LookUpTable.h.

41 { return m_data.end(); }

◆ find() [1/2]

template<class T , class C >
LookUpTable< T, C >::pair_type LookUpTable< T, C >::find ( const val_type val) const
inline

Definition at line 71 of file LookUpTable.h.

71  {
72  vec_type_cit it = lower_bound(m_data.begin(), m_data.end(), val, C());
73  if (it == m_data.end())
74  return std::make_pair(*(it - 2), *(it - 1));
75  else if (it == m_data.begin())
76  return std::make_pair(*it, *(it + 1));
77  else
78  return std::make_pair(*(it - 1), *it);
79 }

◆ find() [2/2]

template<class T , class C = std::less<T>>
template<class CC >
pair_type LookUpTable< T, C >::find ( const val_type val,
const CC &  c 
) const
inline

Definition at line 46 of file LookUpTable.h.

46  {
47  vec_type_cit it = lower_bound(m_data.begin(), m_data.end(), val, c);
48  if (it == m_data.end())
49  return std::make_pair(*(it - 2), *(it - 1));
50  else if (it == m_data.begin())
51  return std::make_pair(*it, *(it + 1));
52  else
53  return std::make_pair(*(it - 1), *it);
54  }

◆ getData()

template<class T , class C = std::less<T>>
const vec_type& LookUpTable< T, C >::getData ( ) const
inline

Definition at line 36 of file LookUpTable.h.

36 { return m_data; }

◆ lowerBound()

template<class T , class C >
LookUpTable< T, C >::vec_type_cit LookUpTable< T, C >::lowerBound ( const val_type val)
inline

Definition at line 65 of file LookUpTable.h.

65  {
66  vec_type_cit it = lower_bound(m_data.begin(), m_data.end(), val, C());
67  if (it == m_data.end()) return m_data.end() - 1;
68  return it;
69 }

◆ setData()

template<class T , class C >
void LookUpTable< T, C >::setData ( const vec_type data)
inline

Definition at line 60 of file LookUpTable.h.

60  {
61  m_data.assign(data.begin(), data.end());
62  sort(m_data.begin(), m_data.end(), C());
63 }

Member Data Documentation

◆ m_data

template<class T , class C = std::less<T>>
vec_type LookUpTable< T, C >::m_data
private

Definition at line 57 of file LookUpTable.h.


The documentation for this class was generated from the following file:
LookUpTable::vec_type_cit
vec_type::const_iterator vec_type_cit
Definition: LookUpTable.h:28
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
DMTest::C
C_v1 C
Definition: C.h:26
skel.it
it
Definition: skel.GENtoEVGEN.py:423
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:554
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
LookUpTable::m_data
vec_type m_data
Definition: LookUpTable.h:57
python.compressB64.c
def c
Definition: compressB64.py:93