ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RangeMap< R, T > Class Template Reference

A container of ranges, somewhat like a set. More...

#include <rangemap.h>

Inheritance diagram for RangeMap< R, T >:

Classes

struct  RangeCompare
 The value attached to each range in this RangeMap. More...
 

Public Types

typedef R Range
 
typedef T Value
 A type having the Range interface, used as keys in the underlying std::map. More...
 
typedef Map::iterator iterator
 
typedef Map::const_iterator const_iterator
 
typedef Map::reverse_iterator reverse_iterator
 
typedef Map::const_reverse_iterator const_reverse_iterator
 

Public Member Functions

 RangeMap ()
 Create a new, empty map. More...
 
template<class Other >
 RangeMap (const Other &other)
 Create a new map from an existing map. More...
 
bool empty () const
 Returns true if this RangeMap is empty. More...
 
size_t nranges () const
 Returns the number of ranges in the range map. More...
 
Range::Value size () const
 Returns the number of values represented by this RangeMap. More...
 
Range::Value min () const
 Returns the minimum value in an extent map. More...
 
Range::Value max () const
 Returns the maximum value in an extent map. More...
 
Range minmax () const
 Returns the range of values in this map. More...
 
void clear (bool notify=true)
 Clears the map. More...
 
void erase (const Range &erase_range)
 Erases the specified range from this map. More...
 
template<class OtherMap >
void erase_ranges (const OtherMap &other)
 Erase ranges from this map. More...
 
iterator insert (Range new_range, Value new_value=Value(), bool make_hole=true)
 Insert a range/value pair into the map. More...
 
void insert_ranges (const RangeMap &x, bool make_hole=true)
 Insert one rangemap into another. More...
 
void insert_ranges (const_iterator start, const_iterator stop, bool make_hole=true)
 Insert part of one rangemap into another. More...
 
bool overlaps (const RangeMap &x) const
 Determines if two range maps overlap. More...
 
bool overlaps (const Range &r) const
 Determines if a range map overlaps with a specified range. More...
 
bool distinct (const Range &r) const
 Determines if a range map does not contain any part of the specified range. More...
 
bool distinct (const RangeMap &x) const
 Determines if two range maps are distinct. More...
 
bool contains (Range need) const
 Determines if this range map contains all of the specified range. More...
 
bool contains (const RangeMap &x) const
 Determins if this range map contains all of some other range map. More...
 
template<class ResultMap >
ResultMap invert () const
 Create an inverse of a range map. More...
 
template<class ResultMap >
ResultMap invert_within (const Range &limits) const
 Create a range map that's the inverse of some other map. More...
 
RangeMap select_overlapping_ranges (const Range &selector) const
 Select ranges overlapping selector range. More...
 
void check () const
 
void print (std::ostream &o) const
 Prints unformatted RangeMap on a single line. More...
 
iterator begin ()
 First-item iterator. More...
 
const_iterator begin () const
 First-item iterator. More...
 
iterator end ()
 End-item iterator. More...
 
const_iterator end () const
 End-item iterator. More...
 
reverse_iterator rbegin ()
 Returns a reverse iterator referring to the last item of the map, the rend() iterator if the RangeMap is empty. More...
 
const_reverse_iterator rbegin () const
 Returns a reverse iterator referring to the last item of the map, the rend() iterator if the RangeMap is empty. More...
 
reverse_iterator rend ()
 Returns a reverse iterator referring to the element right before the first element in the map, which is considered its reverse end. More...
 
const_reverse_iterator rend () const
 Returns a reverse iterator referring to the element right before the first element in the map, which is considered its reverse end. More...
 
iterator find (const typename Range::Value &addr)
 Find the range containing specified value. More...
 
const_iterator find (const typename Range::Value &addr) const
 Find the range containing specified value. More...
 
iterator lower_bound (const typename Range::Value &addr)
 Finds the first range ending above the specified value. More...
 
const_iterator lower_bound (const typename Range::Value &addr) const
 Finds the first range ending above the specified value. More...
 
iterator find_prior (const typename Range::Value &addr)
 Finds the last range starting at or below the specified value. More...
 
const_iterator find_prior (const typename Range::Value &addr) const
 Finds the last range starting at or below the specified value. More...
 
iterator best_fit (const typename Range::Value &size, iterator start)
 Find range with closest size. More...
 
const_iterator best_fit (const typename Range::Value &size, const_iterator start) const
 Find range with closest size. More...
 
iterator first_fit (const typename Range::Value &size, iterator start)
 Find first range of larger size. More...
 
const_iterator first_fit (const typename Range::Value &size, const_iterator start)
 Find first range of larger size. More...
 
iterator find_overlap (const RangeMap &x)
 Find the first overlap between two RangeMap objects. More...
 
const_iterator first_overlap (const RangeMap &x) const
 Find the first overlap between two RangeMap objects. More...
 
iterator find_overlap (iterator start, iterator stop, const RangeMap &x)
 Find an overlap between two RangeMap objects. More...
 
const_iterator find_overlap (const_iterator start, const_iterator stop, const RangeMap &x) const
 Find an overlap between two RangeMap objects. More...
 

Protected Types

typedef std::pair< Range, RangeRangePair
 
typedef std::pair< Range, ValueMapPair
 
typedef std::map< Range, Value,
RangeCompare
Map
 

Protected Attributes

Map ranges
 

Friends

std::ostream & operator<< (std::ostream &o, const RangeMap &rmap)
 

Detailed Description

template<class R, class T = RangeMapVoid<R>>
class RangeMap< R, T >

A container of ranges, somewhat like a set.

The container is able to hold non-overlapping ranges, each of which has some associated value attached to it. Arbitrary ranges can be inserted and erased from the RangeMap without regard to the ranges that are present in the map, since this class can merge and split values (through methods defined on the value) as necessary in order to maintain the non-overlapping invariant. Every attempt was made to optimize this class for storage and execution efficiency and usability. The interface is similar to the std::map interface.

In the simple case, when no data is attached to the ranges in the map, the RangeMap acts somewhat like an std::set with the following differences:

  • The iterator points to a pair whose first member is a Range (the second member is a RangeMapVoid instance with no useful data).
  • The RangeMap uses much less memory than an std::set when the members are mostly contiguous.
  • The find() method is faster when members are mostly contiguous. Both are O(log N) but N is much smaller for a RangeMap than an std::set due to the compression factor.

Here's an example of using the RangeMap as a set. For every CPU instruction in a binary specimen, it adds the addresses of the instruction to the set. In some architectures, such as x86, the instructions might overlap; this approach correctly handles that.

struct InstructionAddresses: public AstSimpleProcessing {
typedef Range<rose_addr_t> AddressRange;
void visit(SgNode *node) {
if (insn!=NULL) {
rose_addr_t start = insn->get_address();
size_t size = insn->get_size();
set.insert(AddressRange(start, size));
}
}
} instruction_addresses;
instruction_addresses.traverse(project, preorder);
std::cout <<"Instructions occupy " <<instruction_addresses.set.size() <<" bytes:\n"
<<instruction_addresses.set;

A more complex example is using a RangeMap to store a value with each range. A simple example follows, where we want to build a RangeMap that associates any address with the function that owns that address, even when functions are discontiguous in the address space. The first step is to define the value type for the RangeMap we'll be using to store this:

typedef Range<rose_addr_t> AddressRange;
class FunctionRangeMapValue: public RangeMapValue<AddressRange, SgAsmFunction*> {
public:
FunctionRangeMapValue(): public RangeMapValue<AddressRange, SgAsmFunction*>(NULL) {}
FunctionRangeMapValue(Function *f): public RangeMapValue<AddressRange, SgAsmFunction*>(f) {}
FunctionRangeMapValue split(const AddressRange&, const AddressRange::Value&) {
return *this;
}
void print(std::ostream &o) const {
if (NULL==value) {
o <<"(null)";
} else {
o <<"F" <<StringUtility::addrToString(get()->entry_va);
}
}
};

Define an AST traversal add each instruction to the RangeMap:

struct FindInstructions: public AstSimpleProcessing {
FunctionRangeMap ranges;
void visit(SgNode *node) {
SgAsmFunction *func = SageInterface::getEnclosingNode<SgAsmFunction>(insn);
if (insn && func) {
rose_addr_t start = insn->get_address();
size_t size = insn->get_size();
ranges.insert(AddressRange(start, size), func);
}
}
};

Finally, traverse the AST and print the result. Because RangeMap merges adjacent ranges when possible, the output will contain the fewest number of ranges needed to describe the entire address space that's assigned to functions. Note that it's possible for two or more functions to "own" the same part of the address space if their instructions overlap, but since we defined our RangeMap to hold only one function pointer per address we'll see only the function that was added last for overlapping ranges.

FindInstructions insn_finder;
insn_finder.traverse(interpretation, preorder);
o <<insn_finder.ranges;

The RangeMap class template can also be specialized to hold more complex values. The value type defines how ranges can be merged and split. RangeMap value types must implement the interface described for RangeMapVoid. Another example of a value type is RangeMapValue, that holds a simple scalar value and determines "mergeabiliy" and "splitability" based on the equality operator. Eventually, MemoryMap might also be rewritten in terms of RangeMap, and will have much more complex rules for merging, splitting, truncating, and removing.

Definition at line 838 of file rangemap.h.

Member Typedef Documentation

template<class R, class T = RangeMapVoid<R>>
typedef R RangeMap< R, T >::Range

Definition at line 840 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
typedef T RangeMap< R, T >::Value

A type having the Range interface, used as keys in the underlying std::map.

Definition at line 841 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
typedef std::pair<Range, Range> RangeMap< R, T >::RangePair
protected

Definition at line 853 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
typedef std::pair<Range, Value> RangeMap< R, T >::MapPair
protected

Definition at line 854 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
typedef std::map<Range, Value, RangeCompare> RangeMap< R, T >::Map
protected

Definition at line 855 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
typedef Map::iterator RangeMap< R, T >::iterator

Definition at line 859 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
typedef Map::const_iterator RangeMap< R, T >::const_iterator

Definition at line 860 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
typedef Map::reverse_iterator RangeMap< R, T >::reverse_iterator

Definition at line 861 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
typedef Map::const_reverse_iterator RangeMap< R, T >::const_reverse_iterator

Definition at line 862 of file rangemap.h.

Constructor & Destructor Documentation

template<class R, class T = RangeMapVoid<R>>
RangeMap< R, T >::RangeMap ( )
inline

Create a new, empty map.

Definition at line 870 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
template<class Other >
RangeMap< R, T >::RangeMap ( const Other &  other)
inlineexplicit

Create a new map from an existing map.

Definition at line 874 of file rangemap.h.

Member Function Documentation

template<class R, class T = RangeMapVoid<R>>
const_iterator RangeMap< R, T >::begin ( ) const
inline

First-item iterator.

Returns an iterator for the first item, or the end iterator if the RangeMap is empty. The iterator is valid until any operation that changes the RangeMap, such as an insert or erase.

Definition at line 894 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
iterator RangeMap< R, T >::end ( )
inline

End-item iterator.

Returns an iterator to the one-past-last item of the RangeMap, regardless of whether the range map is empty. The iterator is valid until any operation that changes the RangeMap, such as an insert or erase.

Definition at line 903 of file rangemap.h.

Referenced by Partitioner::adjust_padding(), MemoryMap::at(), RangeMap< Extent >::best_fit(), RangeMap< Extent >::check(), RangeMap< Extent >::clear(), RangeMap< Extent >::contains(), RangeMap< Extent >::distinct(), MemoryMap::dump(), MemoryMap::erase(), RangeMap< Extent >::erase(), MemoryMap::erase_zeros(), MemoryMap::exists(), SgAsmGenericFile::fill_holes(), RegisterDictionary::filter_nonoverlapping(), RangeMap< Extent >::find(), MemoryMap::find_free(), MemoryMap::find_last_free(), RangeMap< Extent >::find_overlap(), RangeMap< Extent >::find_prior(), RangeMap< Extent >::first_fit(), RangeMap< Extent >::first_overlap(), Partitioner::function_extent(), SgAsmGenericSection::get_referenced_extents(), MemoryMap::init(), MemoryMap::insert(), RangeMap< Extent >::insert(), RangeMap< Extent >::insert_ranges(), RangeMap< Extent >::invert_within(), Disassembler::mark_referenced_instructions(), MemoryMap::mprotect(), Partitioner::FindDataPadding::operator()(), Partitioner::FindData::operator()(), RangeMap< Extent >::overlaps(), RangeMap< Extent >::print(), MemoryMap::prune(), MemoryMap::read1(), Partitioner::scan_unassigned_bytes(), Disassembler::search_next_address(), RangeMap< Extent >::select_overlapping_ranges(), SgAsmGenericFile::shift_extend(), MemoryMap::size(), RangeMap< Extent >::size(), toStringForRTI(), MemoryMap::traverse(), SgAsmGenericSection::unparse(), SgAsmElfStrtab::unparse(), SgAsmCoffStrtab::unparse(), and MemoryMap::write1().

template<class R, class T = RangeMapVoid<R>>
const_iterator RangeMap< R, T >::end ( ) const
inline

End-item iterator.

Returns an iterator to the one-past-last item of the RangeMap, regardless of whether the range map is empty. The iterator is valid until any operation that changes the RangeMap, such as an insert or erase.

Definition at line 906 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
reverse_iterator RangeMap< R, T >::rbegin ( )
inline

Returns a reverse iterator referring to the last item of the map, the rend() iterator if the RangeMap is empty.

The iterator is valid until any operation that changes the RangeMap, such as an insert or erase.

Definition at line 915 of file rangemap.h.

Referenced by SgAsmGenericStrtab::reallocate().

template<class R, class T = RangeMapVoid<R>>
const_reverse_iterator RangeMap< R, T >::rbegin ( ) const
inline

Returns a reverse iterator referring to the last item of the map, the rend() iterator if the RangeMap is empty.

The iterator is valid until any operation that changes the RangeMap, such as an insert or erase.

Definition at line 918 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
reverse_iterator RangeMap< R, T >::rend ( )
inline

Returns a reverse iterator referring to the element right before the first element in the map, which is considered its reverse end.

Notice that rend() does not refer to the same element as begin(), but to the element right before it. The iterator is valid until any operation that changes the RangeMap, such as an insert or erase.

Definition at line 928 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
const_reverse_iterator RangeMap< R, T >::rend ( ) const
inline

Returns a reverse iterator referring to the element right before the first element in the map, which is considered its reverse end.

Notice that rend() does not refer to the same element as begin(), but to the element right before it. The iterator is valid until any operation that changes the RangeMap, such as an insert or erase.

Definition at line 931 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
iterator RangeMap< R, T >::find ( const typename Range::Value addr)
inline

Find the range containing specified value.

Returns an iterator to the Range containing the specified value, or the end() iterator if no such range exists.

Definition at line 940 of file rangemap.h.

Referenced by MemoryMap::at(), RangeMap< Extent >::contains(), MemoryMap::exists(), RangeMap< Extent >::insert(), Disassembler::mark_referenced_instructions(), Partitioner::FindDataPadding::operator()(), Partitioner::FindData::operator()(), MemoryMap::read1(), and MemoryMap::write1().

template<class R, class T = RangeMapVoid<R>>
const_iterator RangeMap< R, T >::find ( const typename Range::Value addr) const
inline

Find the range containing specified value.

Returns an iterator to the Range containing the specified value, or the end() iterator if no such range exists.

Definition at line 946 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
iterator RangeMap< R, T >::lower_bound ( const typename Range::Value addr)
inline
template<class R, class T = RangeMapVoid<R>>
const_iterator RangeMap< R, T >::lower_bound ( const typename Range::Value addr) const
inline

Finds the first range ending above the specified value.

This is similar to the find() method, except it does not return the end() iterator if a range exists above the specified value.

Definition at line 961 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
iterator RangeMap< R, T >::find_prior ( const typename Range::Value addr)
inline

Finds the last range starting at or below the specified value.

Returns the end iterator if there is no range containing a value less than or equal to the specified value.

Definition at line 969 of file rangemap.h.

Referenced by Partitioner::adjust_padding(), MemoryMap::find_last_free(), and Partitioner::FindDataPadding::operator()().

template<class R, class T = RangeMapVoid<R>>
const_iterator RangeMap< R, T >::find_prior ( const typename Range::Value addr) const
inline

Finds the last range starting at or below the specified value.

Returns the end iterator if there is no range containing a value less than or equal to the specified value.

Definition at line 979 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
iterator RangeMap< R, T >::best_fit ( const typename Range::Value size,
iterator  start 
)
inline

Find range with closest size.

Returns an iterator pointing to the first range at or after the specified start iterator whose size is at least as large as the specified size. Returns the end iterator if no such range exists. Note that this is an O(N) algorithm.

Definition at line 996 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
const_iterator RangeMap< R, T >::best_fit ( const typename Range::Value size,
const_iterator  start 
) const
inline

Find range with closest size.

Returns an iterator pointing to the first range at or after the specified start iterator whose size is at least as large as the specified size. Returns the end iterator if no such range exists. Note that this is an O(N) algorithm.

Definition at line 1006 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
iterator RangeMap< R, T >::first_fit ( const typename Range::Value size,
iterator  start 
)
inline

Find first range of larger size.

Returns an iterator to the first range at least as large as the specified size and at or after start. Returns the end iterator if no range is found. Note that this is an O(N) algorithm.

Definition at line 1022 of file rangemap.h.

Referenced by MemoryMap::find_free().

template<class R, class T = RangeMapVoid<R>>
const_iterator RangeMap< R, T >::first_fit ( const typename Range::Value size,
const_iterator  start 
)
inline

Find first range of larger size.

Returns an iterator to the first range at least as large as the specified size and at or after start. Returns the end iterator if no range is found. Note that this is an O(N) algorithm.

Definition at line 1029 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
bool RangeMap< R, T >::empty ( ) const
inline
template<class R, class T = RangeMapVoid<R>>
size_t RangeMap< R, T >::nranges ( ) const
inline

Returns the number of ranges in the range map.

This is the number of Range objects one would encounter if they iterate over this RangeMap from begin() to end().

Definition at line 1050 of file rangemap.h.

Referenced by Partitioner::build_ast(), and SgAsmGenericFile::shift_extend().

template<class R, class T = RangeMapVoid<R>>
Range::Value RangeMap< R, T >::size ( void  ) const
inline

Returns the number of values represented by this RangeMap.

The number of values does not typically correlate with the amount of memory used by the RangeMap since each element of the underlying std::map represents an arbitrary number of values. Note that if the range occupies the entire possible set of values then the size might be returned as zero due to overflow, and it will be necessary to call empty() to make the determination.

Definition at line 1058 of file rangemap.h.

Referenced by SgAsmElfStrtab::allocate_overlap(), RangeMap< Extent >::best_fit(), MemoryMap::dump(), SgAsmGenericFile::dump(), RangeMap< Extent >::first_fit(), Partitioner::is_contiguous(), and SgAsmGenericFile::shift_extend().

template<class R, class T = RangeMapVoid<R>>
Range::Value RangeMap< R, T >::min ( ) const
inline

Returns the minimum value in an extent map.

The extent map must not be empty.

Definition at line 1066 of file rangemap.h.

Referenced by RangeMap< Extent >::minmax(), and Partitioner::FindFunctionFragments::operator()().

template<class R, class T = RangeMapVoid<R>>
Range::Value RangeMap< R, T >::max ( ) const
inline

Returns the maximum value in an extent map.

The extent map must not be empty.

Definition at line 1072 of file rangemap.h.

Referenced by RangeMap< Extent >::minmax().

template<class R, class T = RangeMapVoid<R>>
Range RangeMap< R, T >::minmax ( ) const
inline

Returns the range of values in this map.

Definition at line 1078 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
void RangeMap< R, T >::clear ( bool  notify = true)
inline

Clears the map.

Removes all entries from the map. If notify is true then also call the removing() method of each value.

Definition at line 1095 of file rangemap.h.

Referenced by MemoryMap::clear(), and SgAsmElfStringSection::parse().

template<class R, class T = RangeMapVoid<R>>
void RangeMap< R, T >::erase ( const Range erase_range)
inline

Erases the specified range from this map.

The range to remove can span multiple existing ranges and/or parts of ranges, or no ranges at all. It would be nice to be able to return an iterator to the next item since we have that in hand. Unfortunately, limitations of std::map make this impractical. If you need an iterator, just make another call to lower_bound().

Definition at line 1107 of file rangemap.h.

Referenced by Partitioner::adjust_padding(), MemoryMap::erase(), RangeMap< Extent >::erase_ranges(), SgAsmGenericStrtab::free_all_strings(), RangeMap< Extent >::insert(), Partitioner::FindFunctionFragments::operator()(), MemoryMap::prune(), SgAsmElfStringSection::set_size(), and SgAsmPEStringSection::set_size().

template<class R, class T = RangeMapVoid<R>>
template<class OtherMap >
void RangeMap< R, T >::erase_ranges ( const OtherMap &  other)
inline

Erase ranges from this map.

Every range in the other map is erased from this map. The maps need not be the same type as long as their ranges are the same type. The values of the other map are not used–only its ranges.

Definition at line 1167 of file rangemap.h.

Referenced by RegisterDictionary::filter_nonoverlapping(), Partitioner::find_db_starting(), and Partitioner::scan_unassigned_bytes().

template<class R, class T = RangeMapVoid<R>>
iterator RangeMap< R, T >::insert ( Range  new_range,
Value  new_value = Value(),
bool  make_hole = true 
)
inline

Insert a range/value pair into the map.

If make_hole is true then the new range is allowed to replace existing ranges (or parts thereof), otherwise if the new range conflicts with eixsting ranges the new extent is not inserted and no change is made to the map. If merge is true then we attempt to merge the new range into adjacent ranges. Returns an iterator to the new map element, or if merged, to the element that contains the new value. Returns the end iterator if the range was not inserted.

Definition at line 1178 of file rangemap.h.

Referenced by Partitioner::datablock_extent(), Partitioner::discover_jump_table(), MemoryMap::erase_zeros(), SgAsmGenericFile::fill_holes(), RegisterDictionary::filter_nonoverlapping(), Partitioner::find_db_starting(), SgAsmGenericStrtab::free(), Partitioner::function_extent(), SgAsmFunction::get_extent(), SgAsmGenericSection::get_referenced_extents(), SgAsmPEImportDirectory::hintname_table_extent(), MemoryMap::insert(), RangeMap< Extent >::insert_ranges(), SgAsmGenericFile::mark_referenced_extent(), MemoryMap::mprotect(), Partitioner::FindFunctionFragments::operator()(), MemoryMap::prune(), RangeMap< Extent >::RangeMap(), RangeMap< Extent >::select_overlapping_ranges(), SgAsmElfStringSection::set_size(), SgAsmPEStringSection::set_size(), and SgAsmGenericFile::shift_extend().

template<class R, class T = RangeMapVoid<R>>
void RangeMap< R, T >::insert_ranges ( const RangeMap< R, T > &  x,
bool  make_hole = true 
)
inline

Insert one rangemap into another.

Definition at line 1210 of file rangemap.h.

Referenced by SgAsmGenericStrtab::free(), and RangeMap< Extent >::insert_ranges().

template<class R, class T = RangeMapVoid<R>>
void RangeMap< R, T >::insert_ranges ( const_iterator  start,
const_iterator  stop,
bool  make_hole = true 
)
inline

Insert part of one rangemap into another.

The ranges from start (inclusive) to stop (exclusive) are inserted into this range map. The start and stop iterators should not be iterators of this map, but some other.

Definition at line 1217 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
bool RangeMap< R, T >::overlaps ( const RangeMap< R, T > &  x) const
inline

Determines if two range maps overlap.

Returns true iff any ranges of this map overlap with any ranges of map x.

Definition at line 1228 of file rangemap.h.

Referenced by RangeMap< Extent >::distinct().

template<class R, class T = RangeMapVoid<R>>
bool RangeMap< R, T >::overlaps ( const Range r) const
inline

Determines if a range map overlaps with a specified range.

Returns true iff any part of the range r is present in the map. A RangeMap never overlaps with an empty range.

Definition at line 1234 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
bool RangeMap< R, T >::distinct ( const Range r) const
inline

Determines if a range map does not contain any part of the specified range.

Returns false if any part of the range r is present in the map. An empty range is always distinct from the map.

Definition at line 1243 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
bool RangeMap< R, T >::distinct ( const RangeMap< R, T > &  x) const
inline

Determines if two range maps are distinct.

Returns true iff there is no range in this map that overlaps with any range of map x.

Definition at line 1249 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
bool RangeMap< R, T >::contains ( Range  need) const
inline

Determines if this range map contains all of the specified range.

If the specified range is empty then this function returns true: the map contains all empty ranges.

Definition at line 1255 of file rangemap.h.

Referenced by Partitioner::build_ast(), RangeMap< Extent >::contains(), MemoryMap::exists(), and Partitioner::FindFunctionFragments::operator()().

template<class R, class T = RangeMapVoid<R>>
bool RangeMap< R, T >::contains ( const RangeMap< R, T > &  x) const
inline

Determins if this range map contains all of some other range map.

Returns true iff each range in x is contained in some range of this map. If x is empty this function returns true: a RangeMap contains all empty ranges.

Definition at line 1276 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
iterator RangeMap< R, T >::find_overlap ( const RangeMap< R, T > &  x)
inline

Find the first overlap between two RangeMap objects.

Returns an iterator for this map that points to the first range that overlaps with some range in the other map, x. Returns the end iterator if no overlap is found.

Definition at line 1295 of file rangemap.h.

Referenced by RangeMap< Extent >::find_overlap(), and RangeMap< Extent >::first_overlap().

template<class R, class T = RangeMapVoid<R>>
const_iterator RangeMap< R, T >::first_overlap ( const RangeMap< R, T > &  x) const
inline

Find the first overlap between two RangeMap objects.

Returns an iterator for this map that points to the first range that overlaps with some range in the other map, x. Returns the end iterator if no overlap is found.

Definition at line 1298 of file rangemap.h.

Referenced by RangeMap< Extent >::distinct(), and RangeMap< Extent >::overlaps().

template<class R, class T = RangeMapVoid<R>>
iterator RangeMap< R, T >::find_overlap ( iterator  start,
iterator  stop,
const RangeMap< R, T > &  x 
)
inline

Find an overlap between two RangeMap objects.

Returns an iterator for this map that points to the first range that overlaps with some range in the other map, x. The returned iterator will be between start (inclusive) and stop (exclusive), which must obviously be iterators for this RangeMap, not x. Returns the end iterator if there is no overlap within the restricted ranges.

Definition at line 1309 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
const_iterator RangeMap< R, T >::find_overlap ( const_iterator  start,
const_iterator  stop,
const RangeMap< R, T > &  x 
) const
inline

Find an overlap between two RangeMap objects.

Returns an iterator for this map that points to the first range that overlaps with some range in the other map, x. The returned iterator will be between start (inclusive) and stop (exclusive), which must obviously be iterators for this RangeMap, not x. Returns the end iterator if there is no overlap within the restricted ranges.

Definition at line 1324 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
template<class ResultMap >
ResultMap RangeMap< R, T >::invert ( ) const
inline

Create an inverse of a range map.

The values of the result are default constructed.

Definition at line 1348 of file rangemap.h.

Referenced by MemoryMap::find_free(), MemoryMap::find_last_free(), and Partitioner::scan_unassigned_bytes().

template<class R, class T = RangeMapVoid<R>>
template<class ResultMap >
ResultMap RangeMap< R, T >::invert_within ( const Range limits) const
inline

Create a range map that's the inverse of some other map.

The returned map's ranges will be limited according to the specified limits. The values of the result are default constructed.

Definition at line 1355 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
RangeMap RangeMap< R, T >::select_overlapping_ranges ( const Range selector) const
inline

Select ranges overlapping selector range.

Returns a new range map whose ranges are those ranges of this map that overlap with the specified selector range.

Definition at line 1374 of file rangemap.h.

template<class R, class T = RangeMapVoid<R>>
void RangeMap< R, T >::check ( ) const
inline

Definition at line 1390 of file rangemap.h.

Referenced by RangeMap< Extent >::erase(), and RangeMap< Extent >::insert().

template<class R, class T = RangeMapVoid<R>>
void RangeMap< R, T >::print ( std::ostream &  o) const
inline

Prints unformatted RangeMap on a single line.

Definition at line 1470 of file rangemap.h.

Friends And Related Function Documentation

template<class R, class T = RangeMapVoid<R>>
std::ostream& operator<< ( std::ostream &  o,
const RangeMap< R, T > &  rmap 
)
friend

Definition at line 1480 of file rangemap.h.

Member Data Documentation


The documentation for this class was generated from the following file: