20 #ifndef H_GUARD_INTARENA_H
21 #define H_GUARD_INTARENA_H
29 #include <boost/foreach.hpp>
31 #define IA_AGGRESSIVE_OPTIMIZATION 0
34 template <
typename TInt,
typename TFld>
37 typedef std::set<TFld>
TSet;
65 this->
add(item.first, item.second);
70 this->
sub(item.first, item.second);
75 template <
typename TInt,
typename TFld>
78 const TInt beg = key.first;
79 const TInt end = key.second;
82 cont_[end][beg].insert(fld);
85 template <
typename TInt,
typename TFld>
88 const TInt winBeg = key.first;
89 const TInt winEnd = key.second;
92 std::vector<value_type> recoverList;
94 const typename TCont::iterator itEnd = cont_.end();
95 typename TCont::iterator it =
96 cont_.lower_bound(winBeg + 1);
99 TLine &line = it->second;
100 #if !IA_AGGRESSIVE_OPTIMIZATION
107 typename TLine::iterator lineIt = line.begin();
108 TInt beg = lineIt->first;
115 const TInt end = it->first;
118 const typename TLine::iterator lineItEnd = line.end();
125 TLeaf &os = lineIt->second;
133 recoverList.push_back(item);
137 #if IA_AGGRESSIVE_OPTIMIZATION
140 line.erase(lineIt++);
145 if (lineItEnd == lineIt)
151 while (beg < winEnd);
158 recoverList.push_back(item);
161 #if IA_AGGRESSIVE_OPTIMIZATION
174 BOOST_FOREACH(
const value_type &rItem, recoverList) {
176 const TFld fld = rItem.second;
177 const TInt beg = key.first;
178 const TInt end = key.second;
180 cont_[end][beg].insert(fld);
184 template <
typename TInt,
typename TFld>
187 const TInt winBeg = key.first;
188 const TInt winEnd = key.second;
191 typename TCont::const_iterator it =
192 cont_.lower_bound(winBeg + 1);
194 for (; cont_.end() != it; ++it) {
195 const TLine &line = it->second;
196 #if !IA_AGGRESSIVE_OPTIMIZATION
201 typename TLine::const_iterator lineIt = line.begin();
202 TInt beg = lineIt->first;
207 const typename TLine::const_iterator lineItEnd = line.end();
213 const TLeaf &os = lineIt->second;
214 std::copy(os.begin(), os.end(), std::inserter(dst, dst.begin()));
217 if (lineItEnd == ++lineIt)
223 while (beg < winEnd);
229 template <
typename TInt,
typename TFld>
235 BOOST_FOREACH(
typename TCont::const_reference item, cont_) {
236 key.second = item.first;
237 const TLine &line = item.second;
239 BOOST_FOREACH(
typename TLine::const_reference lineItem, line) {
240 const TLeaf &leaf = lineItem.second;
244 key.first = lineItem.first;
250 template <
typename TInt,
typename TFld>
253 typedef typename TCont::const_iterator TEndIt;
254 const TEndIt itEnd = cont_.find( key.second);
255 if (cont_.end() == itEnd)
259 const TLine &line = itEnd->second;
260 const typename TLine::const_iterator itBeg = line.find( key.first);
261 if (line.end() == itBeg)
265 const TLeaf &leaf = itBeg->second;
266 std::copy(leaf.begin(), leaf.end(), std::inserter(dst, dst.begin()));