#ifndef LLDB_UTILITY_RANGEMAP_H
#define LLDB_UTILITY_RANGEMAP_H
#include <algorithm>
#include <vector>
#include "llvm/ADT/SmallVector.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
template <typename B, typename S> struct Range { … };
template <typename B, typename S, unsigned N = 0> class RangeVector { … };
template <typename B, typename S, typename T>
struct RangeData : public Range<B, S> { … };
template <typename B, typename S, typename T>
struct AugmentedRangeData : public RangeData<B, S, T> { … };
template <typename B, typename S, typename T, unsigned N = 0,
class Compare = std::less<T>>
class RangeDataVector {
public:
typedef lldb_private::Range<B, S> Range;
typedef RangeData<B, S, T> Entry;
typedef AugmentedRangeData<B, S, T> AugmentedEntry;
typedef llvm::SmallVector<AugmentedEntry, N> Collection;
RangeDataVector(Compare compare = Compare()) : … { … }
~RangeDataVector() = default;
void Append(const Entry &entry) { … }
void Append(B &&b, S &&s, T &&t) { … }
bool Erase(uint32_t start, uint32_t end) { … }
void Sort() { … }
#ifdef ASSERT_RANGEMAP_ARE_SORTED
bool IsSorted() const {
typename Collection::const_iterator pos, end, prev;
for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
prev = pos++) {
if (prev != end && *pos < *prev)
return false;
}
return true;
}
#endif
void CombineConsecutiveEntriesWithEqualData() { … }
void Clear() { … }
bool IsEmpty() const { … }
size_t GetSize() const { … }
const Entry *GetEntryAtIndex(size_t i) const { … }
Entry *GetMutableEntryAtIndex(size_t i) { … }
Entry &GetEntryRef(size_t i) { … }
const Entry &GetEntryRef(size_t i) const { … }
static bool BaseLessThan(const Entry &lhs, const Entry &rhs) { … }
uint32_t FindEntryIndexThatContains(B addr) const { … }
uint32_t FindEntryIndexesThatContain(B addr, std::vector<uint32_t> &indexes) { … }
Entry *FindEntryThatContains(B addr) { … }
const Entry *FindEntryThatContains(B addr) const { … }
const Entry *FindEntryThatContains(const Entry &range) const { … }
const Entry *FindEntryStartsAt(B addr) const { … }
const Entry *FindEntryThatContainsOrFollows(B addr) const { … }
uint32_t FindEntryIndexThatContainsOrFollows(B addr) const { … }
Entry *Back() { … }
const Entry *Back() const { … }
using const_iterator = typename Collection::const_iterator;
const_iterator begin() const { … }
const_iterator end() const { … }
protected:
Collection m_entries;
Compare m_compare;
private:
B ComputeUpperBounds(size_t lo, size_t hi) { … }
void FindEntryIndexesThatContain(B addr, size_t lo, size_t hi,
std::vector<uint32_t> &indexes) { … }
};
template <typename B, typename T> struct AddressData { … };
template <typename B, typename T, unsigned N> class AddressDataArray { … };
}
#endif