vrpRouting  0.3
Identifiers< T > Class Template Reference

#include "identifiers.hpp"

Inheritance diagram for Identifiers< T >:
Collaboration diagram for Identifiers< T >:

Public Types

typedef std::set< T >::const_iterator const_iterator
 
typedef std::set< T >::iterator iterator
 

Public Member Functions

constructors
 Identifiers ()=default
 
 Identifiers (const Identifiers< T > &)=default
 
 Identifiers (const std::set< T > &data)
 
 Identifiers (const size_t number)
 

Friends

std::ostream & operator<< (std::ostream &os, const Identifiers< T > &identifiers)
 Prints the set of identifiers. More...
 

set like operators

std::set< T > m_ids
 
size_t size () const
 
bool empty () const
 
front () const
 
back () const
 
const_iterator begin () const
 
const_iterator end () const
 
void pop_front ()
 
void clear ()
 
iterator begin ()
 
iterator end ()
 
bool has (const T other) const
 true ids() has element More...
 
bool operator== (const Identifiers< T > &rhs) const
 true when both sets are equal More...
 

set UNION

Identifiers< T > & operator+= (const Identifiers< T > &other)
 compound set UNION set More...
 
Identifiers< T > & operator+= (const T &element)
 compound set UNION element More...
 
Identifiers< T > operator+ (const Identifiers< T > &lhs, const Identifiers< T > &rhs)
 set UNION set More...
 

set INTERSECTION

Identifiers< T > & operator*= (const Identifiers< T > &other)
 coumpound set INTERSECTION set More...
 
Identifiers< T > & operator*= (const T &element)
 compund set INTERSECTION element More...
 
Identifiers< T > operator* (const Identifiers< T > &lhs, const Identifiers< T > &rhs)
 set INTERSECTION More...
 

set DIFFERENCE

Identifiers< T > & operator-= (const Identifiers< T > &other)
 compound set DIFFERENCE set More...
 
Identifiers< T > & operator-= (const T &element)
 compund set DIFFERENCE element More...
 
Identifiers< T > operator- (const Identifiers< T > &lhs, const Identifiers< T > &rhs)
 

Detailed Description

template<typename T>
class Identifiers< T >

Definition at line 51 of file identifiers.hpp.

Member Typedef Documentation

◆ const_iterator

template<typename T >
typedef std::set<T>::const_iterator Identifiers< T >::const_iterator

Definition at line 54 of file identifiers.hpp.

◆ iterator

template<typename T >
typedef std::set<T>::iterator Identifiers< T >::iterator

Definition at line 53 of file identifiers.hpp.

Constructor & Destructor Documentation

◆ Identifiers() [1/4]

template<typename T >
Identifiers< T >::Identifiers ( )
default

◆ Identifiers() [2/4]

template<typename T >
Identifiers< T >::Identifiers ( const Identifiers< T > &  )
default

◆ Identifiers() [3/4]

template<typename T >
Identifiers< T >::Identifiers ( const std::set< T > &  data)
inlineexplicit

Definition at line 61 of file identifiers.hpp.

61  {
62  m_ids = data;
63  }

◆ Identifiers() [4/4]

template<typename T >
Identifiers< T >::Identifiers ( const size_t  number)
inlineexplicit

Definition at line 69 of file identifiers.hpp.

69  {
70  std::generate_n(std::inserter(m_ids, m_ids.end()), number, [&]{ return m_ids.size(); });
71  }

Member Function Documentation

◆ back()

template<typename T >
T Identifiers< T >::back ( ) const
inline

Definition at line 80 of file identifiers.hpp.

80 {return *m_ids.end();}

Referenced by vrprouting::problem::Fleet::get_truck().

◆ begin() [1/2]

template<typename T >
iterator Identifiers< T >::begin ( )
inline

Definition at line 87 of file identifiers.hpp.

87 {return m_ids.begin();}

◆ begin() [2/2]

◆ clear()

template<typename T >
void Identifiers< T >::clear ( )
inline

Definition at line 86 of file identifiers.hpp.

86 {m_ids.clear();}

◆ empty()

◆ end() [1/2]

template<typename T >
iterator Identifiers< T >::end ( )
inline

Definition at line 88 of file identifiers.hpp.

88 {return m_ids.end();}

◆ end() [2/2]

template<typename T >
const_iterator Identifiers< T >::end ( ) const
inline

Definition at line 82 of file identifiers.hpp.

82 {return m_ids.end();}

Referenced by vrprouting::base::Base_Matrix::Base_Matrix(), and vrprouting::base::Base_Matrix::set_ids().

◆ front()

◆ has()

template<typename T >
bool Identifiers< T >::has ( const T  other) const
inline

◆ operator*=() [1/2]

template<typename T >
Identifiers<T>& Identifiers< T >::operator*= ( const Identifiers< T > &  other)
inline

coumpound set INTERSECTION set

Parameters
[in]otheris a set of identifiers of type Identifiers<T>

Definition at line 176 of file identifiers.hpp.

177  {
178  *this = *this * other;
179  return *this;
180  }

◆ operator*=() [2/2]

template<typename T >
Identifiers<T>& Identifiers< T >::operator*= ( const T &  element)
inline

compund set INTERSECTION element

Parameters
[in]elementis an identifiers of type T

Definition at line 186 of file identifiers.hpp.

186  {
187  if (has(element)) {
188  m_ids.clear();
189  m_ids.insert(element);
190  } else {
191  m_ids.clear();
192  }
193  return *this;
194  }

◆ operator+=() [1/2]

template<typename T >
Identifiers<T>& Identifiers< T >::operator+= ( const Identifiers< T > &  other)
inline

compound set UNION set

Parameters
[in]otherset of identifiers

Definition at line 133 of file identifiers.hpp.

134  {
135  m_ids.insert(other.m_ids.begin(), other.m_ids.end());
136  return *this;
137  }

◆ operator+=() [2/2]

template<typename T >
Identifiers<T>& Identifiers< T >::operator+= ( const T &  element)
inline

compound set UNION element

Parameters
[in]elementof type T

Definition at line 142 of file identifiers.hpp.

142  {
143  m_ids.insert(element);
144  return *this;
145  }

◆ operator-=() [1/2]

template<typename T >
Identifiers<T>& Identifiers< T >::operator-= ( const Identifiers< T > &  other)
inline

compound set DIFFERENCE set

Parameters
[in]otheris a set of identifiers of type Identifiers<T> Replaces this set with the set difference between this set and other

Definition at line 226 of file identifiers.hpp.

226  {
227  *this = *this - other;
228  return *this;
229  }

◆ operator-=() [2/2]

template<typename T >
Identifiers<T>& Identifiers< T >::operator-= ( const T &  element)
inline

compund set DIFFERENCE element

Parameters
[in]elementto be removed

Definition at line 235 of file identifiers.hpp.

235  {
236  m_ids.erase(element);
237  return *this;
238  }

◆ operator==()

template<typename T >
bool Identifiers< T >::operator== ( const Identifiers< T > &  rhs) const
inline

true when both sets are equal

Parameters
[in]rhsset of identifiers to be compared

Definition at line 109 of file identifiers.hpp.

109  {
110  return m_ids.size() == rhs.m_ids.size() && std::equal(m_ids.begin(), m_ids.end(), rhs.m_ids.begin());
111  }

◆ pop_front()

template<typename T >
void Identifiers< T >::pop_front ( )
inline

Definition at line 84 of file identifiers.hpp.

84 {m_ids.erase(m_ids.begin());}

Referenced by vrprouting::initialsol::simple::Initial_solution::one_truck_all_orders().

◆ size()

Friends And Related Function Documentation

◆ operator*

template<typename T >
Identifiers<T> operator* ( const Identifiers< T > &  lhs,
const Identifiers< T > &  rhs 
)
friend

set INTERSECTION

Parameters
[in]lhsIdentifiers
[in]rhsIdentifiers

Definition at line 161 of file identifiers.hpp.

163  {
164  std::set<T> result;
165  std::set_intersection(
166  lhs.m_ids.begin(), lhs.m_ids.end(),
167  rhs.m_ids.begin(), rhs.m_ids.end(),
168  std::inserter(result, result.begin()));
169  return Identifiers<T>(result);
170  }

◆ operator+

template<typename T >
Identifiers<T> operator+ ( const Identifiers< T > &  lhs,
const Identifiers< T > &  rhs 
)
friend

set UNION set

Parameters
[in]lhsIdentifiers
[in]rhsIdentifiers

Definition at line 121 of file identifiers.hpp.

123  {
124  Identifiers<T> union_ids(lhs);
125  union_ids += rhs;
126  return union_ids;
127  }

◆ operator-

template<typename T >
Identifiers<T> operator- ( const Identifiers< T > &  lhs,
const Identifiers< T > &  rhs 
)
friend

Definition at line 208 of file identifiers.hpp.

210  {
211  std::set<T> result;
212  std::set_difference(
213  lhs.m_ids.begin(), lhs.m_ids.end(),
214  rhs.m_ids.begin(), rhs.m_ids.end(),
215  std::inserter(result, result.begin()));
216  return Identifiers<T>(result);
217  }

◆ operator<<

template<typename T >
std::ostream& operator<< ( std::ostream &  os,
const Identifiers< T > &  identifiers 
)
friend

Prints the set of identifiers.

Definition at line 245 of file identifiers.hpp.

245  {
246  os << "{";
247  for (auto identifier : identifiers.m_ids) {
248  os << identifier << ", ";
249  }
250  os << "}";
251  return os;
252  }

Member Data Documentation

◆ m_ids


The documentation for this class was generated from the following file:
Identifiers::m_ids
std::set< T > m_ids
Definition: identifiers.hpp:93
Identifiers::has
bool has(const T other) const
true ids() has element
Definition: identifiers.hpp:100
Identifiers
Definition: identifiers.hpp:51