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 #ifndef PDF_RANGE_SET_H_ | |
6 #define PDF_RANGE_SET_H_ | |
7 | |
8 #include <set> | |
9 #include <string> | |
10 | |
11 #include "ui/gfx/range/range.h" | |
12 | |
13 namespace chrome_pdf { | |
14 | |
15 class RangeSet { | |
Lei Zhang
2016/10/05 07:18:08
In general, it would be nice to have a description
snake
2016/10/05 14:14:10
Done.
| |
16 public: | |
17 RangeSet(); | |
18 explicit RangeSet(const gfx::Range& range); | |
19 ~RangeSet(); | |
20 | |
21 void Union(const gfx::Range& range); | |
22 void Union(const RangeSet& range_set); | |
23 | |
24 bool Contains(uint32_t point) const; | |
25 bool Contains(const gfx::Range& range) const; | |
26 bool Contains(const RangeSet& range_set) const; | |
27 | |
28 bool Intersects(const gfx::Range& range) const; | |
29 bool Intersects(const RangeSet& range_set) const; | |
30 | |
31 void Intersect(const gfx::Range& range); | |
32 void Intersect(const RangeSet& range_set); | |
33 | |
34 void Subtract(const gfx::Range& range); | |
35 void Subtract(const RangeSet& range_set); | |
36 | |
37 void Diff(const gfx::Range& range); | |
38 void Diff(const RangeSet& range_set); | |
39 | |
40 bool IsEmpty() const; | |
41 void Clear(); | |
42 | |
43 gfx::Range First() const; | |
44 gfx::Range Last() const; | |
45 std::string ToString() const; | |
46 | |
47 struct range_compare { | |
48 bool operator()(const gfx::Range& lval, const gfx::Range& rval) const { | |
49 return lval.start() < rval.start(); | |
50 } | |
51 }; | |
52 | |
53 typedef std::set<gfx::Range, range_compare> RangesContainer; | |
54 | |
55 const RangesContainer& ranges() const { return ranges_; } | |
56 int Size() const { return static_cast<int>(ranges_.size()); } | |
Lei Zhang
2016/10/05 07:18:08
Can this just return size_t and not cast?
snake
2016/10/05 14:14:10
Done.
| |
57 | |
58 private: | |
59 RangesContainer ranges_; | |
60 }; | |
61 | |
62 } // namespace chrome_pdf | |
63 | |
64 inline bool operator==(const chrome_pdf::RangeSet& lhs, | |
65 const chrome_pdf::RangeSet& rhs) { | |
66 return lhs.ranges() == rhs.ranges(); | |
67 } | |
68 | |
69 inline bool operator!=(const chrome_pdf::RangeSet& lhs, | |
70 const chrome_pdf::RangeSet& rhs) { | |
71 return !(lhs == rhs); | |
72 } | |
73 #endif // PDF_RANGE_SET_H_ | |
OLD | NEW |