NFC: Simplify UseRange::iterator to just be a std::vector::const_iterator.

At some point the implementation of UseRange was more complex, but now it is just a simple wrapper around a std::vector<SymbolUse>.

PiperOrigin-RevId: 277597294
This commit is contained in:
River Riddle 2019-10-30 15:25:35 -07:00 committed by A. Unique TensorFlower
parent d423d4a338
commit e55bd90bc7
1 changed files with 4 additions and 20 deletions

View File

@ -91,27 +91,11 @@ public:
/// This class implements a range of SymbolRef uses.
class UseRange {
public:
/// This class implements an iterator over the symbol use range.
class iterator final
: public indexed_accessor_iterator<iterator, const UseRange *,
const SymbolUse> {
public:
const SymbolUse *operator->() const { return &object->uses[index]; }
const SymbolUse &operator*() const { return object->uses[index]; }
private:
iterator(const UseRange *owner, ptrdiff_t it)
: indexed_accessor_iterator<iterator, const UseRange *,
const SymbolUse>(owner, it) {}
/// Allow access to the constructor.
friend class UseRange;
};
/// Contruct a UseRange from a given set of uses.
UseRange(std::vector<SymbolUse> &&uses) : uses(std::move(uses)) {}
iterator begin() const { return iterator(this, /*it=*/0); }
iterator end() const { return iterator(this, /*it=*/uses.size()); }
using iterator = std::vector<SymbolUse>::const_iterator;
iterator begin() const { return uses.begin(); }
iterator end() const { return uses.end(); }
private:
std::vector<SymbolUse> uses;