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" );
101 return AssociationVectorIterator( *m_store );
105 AssociationVectorIterator
next() { ++m_actual;
return *
this; }
106 AssociationVectorIterator prev() { --m_actual;
return *
this; }
108 AssociationVectorIterator
find(
const asso_type* anAsso)
const
110 typename asso_store::const_iterator assoEnd = m_store->end();
113 for (
typename asso_store::const_iterator itr = m_store->begin();
114 itr != assoEnd; ++itr ) {
115 if ( **itr == anAsso ) {
116 return AssociationVectorIterator( *m_store, itr );
129 AssociationVectorIterator
tmp(*
this);
135 AssociationVectorIterator
operator++(
int) {
return this->
next(); }
138 AssociationVectorIterator operator--() {
return this->prev(); }
141 AssociationVectorIterator operator--(
int)
143 AssociationVectorIterator
tmp(*
this);
150 bool operator==(
const AssociationVectorIterator& anOther)
const
151 {
return m_actual == anOther.m_actual; }
155 bool operator!=(
const AssociationVectorIterator& anOther)
const
156 {
return m_actual != anOther.m_actual; }
161 return m_actual != m_store->end()
165 const asso_type* operator->()
const
167 return m_actual != m_store->end()
179 return m_actual != m_store->end() && m_actual->isValid();
186 size_t size()
const {
return m_store->size(); }
192 AssociationVectorIterator() :
200 const asso_store* m_store;
204 typename asso_store::const_iterator m_actual;
207 #endif // ASSOCIATION_CONTEXT