OLD | NEW |
| (Empty) |
1 // Copyright 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 bool Contains(uint32_t point) const; | |
32 bool Contains(const gfx::Range& range) const; | |
33 bool Contains(const RangeSet& range_set) const; | |
34 | |
35 bool Intersects(const gfx::Range& range) const; | |
36 bool Intersects(const RangeSet& range_set) const; | |
37 | |
38 void Union(const gfx::Range& range); | |
39 void Union(const RangeSet& range_set); | |
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); | |
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; | |
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 using RangesContainer = std::set<gfx::Range, range_compare>; | |
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 |