5 #ifdef ASSOCIATION_CONTEXT
14 class AssociationVectorIterator
17 using iterator_category = std::bidirectional_iterator_tag;
19 using difference_type = std::ptrdiff_t;
31 AssociationVectorIterator(
const asso_store& assoStore)
33 , m_actual(assoStore.
begin())
44 AssociationVectorIterator(
const asso_store& assoStore,
45 const asso_store_iterator&
pos)
51 ~AssociationVectorIterator() { };
61 AssociationVectorIterator
begin()
64 return AssociationVectorIterator(*m_store);
66 throw std::runtime_error(
"Null pointer to store of associations" );
68 return AssociationVectorIterator( *m_store );
72 AssociationVectorIterator
end()
75 return AssociationVectorIterator(*m_store);
77 throw std::runtime_error(
"Null pointer to store of associations" );
79 return AssociationVectorIterator( *m_store );
83 AssociationVectorIterator
begin()
const
86 return AssociationVectorIterator(*m_store, m_store->begin());
88 throw std::runtime_error(
"Null pointer to store of associations" );
90 return AssociationVectorIterator( *m_store );
94 AssociationVectorIterator
end()
const
97 return AssociationVectorIterator(*m_store, m_store->end());
99 throw std::runtime_error(
"Null pointer to store of associations" );
103 AssociationVectorIterator
next() { ++m_actual;
return *
this; }
104 AssociationVectorIterator prev() { --m_actual;
return *
this; }
106 AssociationVectorIterator
find(
const asso_type* anAsso)
const
108 typename asso_store::const_iterator assoEnd = m_store->end();
111 for (
typename asso_store::const_iterator itr = m_store->begin();
112 itr != assoEnd; ++itr ) {
113 if ( **itr == anAsso ) {
114 return AssociationVectorIterator( *m_store, itr );
127 AssociationVectorIterator
tmp(*
this);
133 AssociationVectorIterator
operator++(
int) {
return this->
next(); }
136 AssociationVectorIterator operator--() {
return this->prev(); }
139 AssociationVectorIterator operator--(
int)
141 AssociationVectorIterator
tmp(*
this);
148 bool operator==(
const AssociationVectorIterator& anOther)
const
149 {
return m_actual == anOther.m_actual; }
153 bool operator!=(
const AssociationVectorIterator& anOther)
const
154 {
return m_actual != anOther.m_actual; }
159 return m_actual != m_store->end()
163 const asso_type* operator->()
const
165 return m_actual != m_store->end()
177 return m_actual != m_store->end() && m_actual->isValid();
184 size_t size()
const {
return m_store->size(); }
190 AssociationVectorIterator() :
198 const asso_store* m_store;
202 typename asso_store::const_iterator m_actual;
205 #endif // ASSOCIATION_CONTEXT