Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Defines a set of geometric ranges, and standard operations on it. | |
| 6 | |
| 7 #ifndef PDF_RANGE_SET_H_ | |
| 8 #define PDF_RANGE_SET_H_ | |
| 9 | |
| 10 #include <ostream> | |
| 11 #include <set> | |
| 12 #include <string> | |
| 13 | |
| 14 #include "ui/gfx/range/range.h" | |
| 15 | |
| 16 namespace chrome_pdf { | |
| 17 | |
| 18 class RangeSet { | |
| 19 public: | |
| 20 RangeSet(); | |
| 21 explicit RangeSet(const gfx::Range& range); | |
| 22 ~RangeSet(); | |
| 23 | |
| 24 RangeSet(const RangeSet& range_set); | |
| 25 RangeSet(RangeSet&& range_set); | |
| 26 RangeSet& operator=(const RangeSet& other); | |
| 27 | |
| 28 bool operator==(const RangeSet& other) const; | |
| 29 bool operator!=(const RangeSet& other) const; | |
| 30 | |
| 31 void Union(const gfx::Range& range); | |
|
Lei Zhang
2016/10/21 09:33:10
Put this with the other RangeSet modifiers.
snake
2016/10/21 15:13:15
What do you mean?
Lei Zhang
2016/10/25 06:01:49
What I mean is, you have Contains() and Intersects
snake
2016/10/25 13:57:34
Done.
| |
| 32 void Union(const RangeSet& range_set); | |
| 33 | |
| 34 bool Contains(uint32_t point) const; | |
| 35 bool Contains(const gfx::Range& range) const; | |
| 36 bool Contains(const RangeSet& range_set) const; | |
| 37 | |
| 38 bool Intersects(const gfx::Range& range) const; | |
| 39 bool Intersects(const RangeSet& range_set) const; | |
| 40 | |
| 41 void Intersect(const gfx::Range& range); | |
| 42 void Intersect(const RangeSet& range_set); | |
| 43 | |
| 44 void Subtract(const gfx::Range& range); | |
| 45 void Subtract(const RangeSet& range_set); | |
| 46 | |
| 47 void Xor(const gfx::Range& range); | |
|
Lei Zhang
2016/10/21 09:33:10
Is this ever going to get used in anything but uni
snake
2016/10/21 15:13:15
I want to use it in my next CLs. Also, it is part
Lei Zhang
2016/10/25 06:01:49
Ok, got it. If you are going to use it soon, then
| |
| 48 void Xor(const RangeSet& range_set); | |
| 49 | |
| 50 bool IsEmpty() const; | |
| 51 void Clear(); | |
| 52 | |
| 53 gfx::Range First() const; | |
| 54 gfx::Range Last() const; | |
| 55 std::string ToString() const; | |
|
Lei Zhang
2016/10/21 09:33:10
Are ToString() and operator<< only used in one uni
snake
2016/10/21 15:13:15
It will be used in other unit test files.
| |
| 56 | |
| 57 struct range_compare { | |
| 58 bool operator()(const gfx::Range& lval, const gfx::Range& rval) const { | |
| 59 return lval.start() < rval.start(); | |
| 60 } | |
| 61 }; | |
| 62 | |
| 63 typedef std::set<gfx::Range, range_compare> RangesContainer; | |
|
Lei Zhang
2016/10/21 09:33:10
not: using foo = bar, instead of typedef bar foo.
snake
2016/10/21 15:13:15
Done.
| |
| 64 | |
| 65 const RangesContainer& ranges() const { return ranges_; } | |
| 66 size_t Size() const { return ranges_.size(); } | |
| 67 | |
| 68 private: | |
| 69 RangesContainer ranges_; | |
| 70 }; | |
| 71 | |
| 72 } // namespace chrome_pdf | |
| 73 | |
| 74 std::ostream& operator<<(std::ostream& os, | |
| 75 const chrome_pdf::RangeSet& range_set); | |
| 76 | |
| 77 #endif // PDF_RANGE_SET_H_ | |
| OLD | NEW |