OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // IntervalSet<T> is a data structure used to represent a sorted set of | 5 // IntervalSet<T> is a data structure used to represent a sorted set of |
6 // non-empty, non-adjacent, and mutually disjoint intervals. Mutations to an | 6 // non-empty, non-adjacent, and mutually disjoint intervals. Mutations to an |
7 // interval set preserve these properties, altering the set as needed. For | 7 // interval set preserve these properties, altering the set as needed. For |
8 // example, adding [2, 3) to a set containing only [1, 2) would result in the | 8 // example, adding [2, 3) to a set containing only [1, 2) would result in the |
9 // set containing the single interval [1, 3). | 9 // set containing the single interval [1, 3). |
10 // | 10 // |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 #include <stddef.h> | 55 #include <stddef.h> |
56 | 56 |
57 #include <algorithm> | 57 #include <algorithm> |
58 #include <set> | 58 #include <set> |
59 #include <string> | 59 #include <string> |
60 #include <utility> | 60 #include <utility> |
61 #include <vector> | 61 #include <vector> |
62 | 62 |
63 #include "base/logging.h" | 63 #include "base/logging.h" |
64 #include "net/quic/interval.h" | 64 #include "net/quic/core/interval.h" |
65 | 65 |
66 namespace net { | 66 namespace net { |
67 | 67 |
68 template <typename T> | 68 template <typename T> |
69 class IntervalSet { | 69 class IntervalSet { |
70 private: | 70 private: |
71 struct IntervalComparator { | 71 struct IntervalComparator { |
72 bool operator()(const Interval<T>& a, const Interval<T>& b) const; | 72 bool operator()(const Interval<T>& a, const Interval<T>& b) const; |
73 }; | 73 }; |
74 typedef std::set<Interval<T>, IntervalComparator> Set; | 74 typedef std::set<Interval<T>, IntervalComparator> Set; |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 template <typename T> | 848 template <typename T> |
849 inline bool IntervalSet<T>::IntervalComparator::operator()( | 849 inline bool IntervalSet<T>::IntervalComparator::operator()( |
850 const Interval<T>& a, | 850 const Interval<T>& a, |
851 const Interval<T>& b) const { | 851 const Interval<T>& b) const { |
852 return (a.min() < b.min() || (a.min() == b.min() && a.max() > b.max())); | 852 return (a.min() < b.min() || (a.min() == b.min() && a.max() > b.max())); |
853 } | 853 } |
854 | 854 |
855 } // namespace net | 855 } // namespace net |
856 | 856 |
857 #endif // NET_QUIC_INTERVAL_SET_H_ | 857 #endif // NET_QUIC_INTERVAL_SET_H_ |
OLD | NEW |