Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1129)

Unified Diff: pdf/range_set.h

Issue 2349753003: Improve linearized pdf load/show time. (Closed)
Patch Set: remove useless code. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pdf/range_set.h
diff --git a/pdf/range_set.h b/pdf/range_set.h
new file mode 100644
index 0000000000000000000000000000000000000000..06a2577499689e7d3fd8ecbad0963d81032197df
--- /dev/null
+++ b/pdf/range_set.h
@@ -0,0 +1,73 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PDF_RANGE_SET_H_
+#define PDF_RANGE_SET_H_
+
+#include <set>
+#include <string>
+
+#include "ui/gfx/range/range.h"
+
+namespace chrome_pdf {
+
+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.
+ public:
+ RangeSet();
+ explicit RangeSet(const gfx::Range& range);
+ ~RangeSet();
+
+ void Union(const gfx::Range& range);
+ void Union(const RangeSet& range_set);
+
+ bool Contains(uint32_t point) const;
+ bool Contains(const gfx::Range& range) const;
+ bool Contains(const RangeSet& range_set) const;
+
+ bool Intersects(const gfx::Range& range) const;
+ bool Intersects(const RangeSet& range_set) const;
+
+ void Intersect(const gfx::Range& range);
+ void Intersect(const RangeSet& range_set);
+
+ void Subtract(const gfx::Range& range);
+ void Subtract(const RangeSet& range_set);
+
+ void Diff(const gfx::Range& range);
+ void Diff(const RangeSet& range_set);
+
+ bool IsEmpty() const;
+ void Clear();
+
+ gfx::Range First() const;
+ gfx::Range Last() const;
+ std::string ToString() const;
+
+ struct range_compare {
+ bool operator()(const gfx::Range& lval, const gfx::Range& rval) const {
+ return lval.start() < rval.start();
+ }
+ };
+
+ typedef std::set<gfx::Range, range_compare> RangesContainer;
+
+ const RangesContainer& ranges() const { return ranges_; }
+ 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.
+
+ private:
+ RangesContainer ranges_;
+};
+
+} // namespace chrome_pdf
+
+inline bool operator==(const chrome_pdf::RangeSet& lhs,
+ const chrome_pdf::RangeSet& rhs) {
+ return lhs.ranges() == rhs.ranges();
+}
+
+inline bool operator!=(const chrome_pdf::RangeSet& lhs,
+ const chrome_pdf::RangeSet& rhs) {
+ return !(lhs == rhs);
+}
+#endif // PDF_RANGE_SET_H_

Powered by Google App Engine
This is Rietveld 408576698