20 #ifndef H_GUARD_ID_MAPPER_H
21 #define H_GUARD_ID_MAPPER_H
30 #include <boost/foreach.hpp>
31 #include <boost/static_assert.hpp>
38 template <
typename TId,
39 TId MIN = std::numeric_limits<TId>::min(),
40 TId MAX = std::numeric_limits<TId>::max()>
98 bool insert(TId left, TId right);
100 template <EDirection>
103 template <EDirection>
112 typedef typename TSearch::const_iterator
TIter;
131 template <EDirection DIR,
typename TBiMap,
class TDst,
class TSrc>
137 BOOST_FOREACH(
typename TSrc::value_type src, srcCont) {
138 typename TBiMap::TVector dstVect;
139 biMap.template query<DIR>(&dstVect, src);
140 BOOST_FOREACH(
const typename TDst::value_type dst, dstVect)
141 pDstCont->insert(dst);
145 template <
typename TId, TId MIN, TId MAX>
148 const TPair itemL(left, right);
149 const TPair itemR(right, left);
160 template <
typename TId, TId MIN, TId MAX>
161 template <EDirection DIR>
164 BOOST_STATIC_ASSERT(MIN < MAX);
166 const TSearch &search = biSearch_[DIR];
168 const TPair begItem(
id, MIN);
169 const TIter beg = search.lower_bound(begItem);
170 if (beg == search.end() || beg->first != id) {
173 case NFA_TRAP_TO_DEBUGGER:
174 CL_BREAK_IF(
"IdMapper failed to resolve the requested ID");
177 case NFA_RETURN_NOTHING:
180 case NFA_RETURN_IDENTITY:
187 const TPair endItem(
id, MAX);
188 const TIter end = search.upper_bound(endItem);
192 for (
TIter it = beg; it != end; ++it) {
194 pDst->push_back(it->second);
198 template <
typename TId, TId MIN, TId MAX>
199 template <EDirection DIR>
205 const TSearch &m = biSearch_[DIR];
206 BOOST_FOREACH(
typename TSearch::const_reference item, m) {
207 const TId a = item.first;
208 const TId b = item.second;
210 by.
query<DIR>(&cList, b);
211 BOOST_FOREACH(
const TId c, cList)
215 if (NFA_RETURN_IDENTITY == nfa_) {
218 BOOST_FOREACH(
typename TSearch::const_reference item, mBy) {
219 const TId b = item.first;
220 const TId c = item.second;
225 this->query<D_RIGHT_TO_LEFT>(&aList, b);
227 this->query<D_LEFT_TO_RIGHT>(&aList, b);
229 BOOST_FOREACH(
const TId a, aList)
242 template <
typename TId, TId MIN, TId MAX>
247 BOOST_FOREACH(
typename TSearch::const_reference item, m) {
251 str << item.first <<
" -> " << item.second;