{
return find(r, [r](const AddrRange r1) { return r.isSubset(r1); });
}
+ iterator
+ contains(const AddrRange &r)
+ {
+ return find(r, [r](const AddrRange r1) { return r.isSubset(r1); });
+ }
/**
* Find entry that contains the given address
{
return contains(RangeSize(r, 1));
}
+ iterator
+ contains(Addr r)
+ {
+ return contains(RangeSize(r, 1));
+ }
/**
* Find entry that intersects with the given address range
{
return find(r, [r](const AddrRange r1) { return r.intersects(r1); });
}
+ iterator
+ intersects(const AddrRange &r)
+ {
+ return find(r, [r](const AddrRange r1) { return r.intersects(r1); });
+ }
- const_iterator
+ iterator
insert(const AddrRange &r, const V& d)
{
if (intersects(r) != end())
* @param it Iterator to the entry in the address range map
*/
void
- addNewEntryToCache(const_iterator it) const
+ addNewEntryToCache(iterator it) const
{
if (max_cache_size != 0) {
// If there's a cache, add this element to it.
* @param f A condition on an address range
* @return An iterator that contains the input address range
*/
- const_iterator
- find(const AddrRange &r, std::function<bool(const AddrRange)> cond) const
+ iterator
+ find(const AddrRange &r, std::function<bool(const AddrRange)> cond)
{
// Check the cache first
for (auto c = cache.begin(); c != cache.end(); c++) {
}
}
- const_iterator next = tree.upper_bound(r);
+ iterator next = tree.upper_bound(r);
if (next != end() && cond(next->first)) {
addNewEntryToCache(next);
return next;
return end();
next--;
- const_iterator i;
+ iterator i;
do {
i = next;
if (cond(i->first)) {
return end();
}
+ const_iterator
+ find(const AddrRange &r, std::function<bool(const AddrRange)> cond) const
+ {
+ return const_cast<AddrRangeMap *>(this)->find(r, cond);
+ }
+
RangeMap tree;
/**
* used to optimize lookups. The elements in the list should
* always be valid iterators of the tree.
*/
- mutable std::list<const_iterator> cache;
+ mutable std::list<iterator> cache;
};
#endif //__BASE_ADDR_RANGE_MAP_HH__