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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // | 46 // |
47 // intervals.Difference(Interval<int>(10, 20)); | 47 // intervals.Difference(Interval<int>(10, 20)); |
48 // // intervals should now contain the single range [20, 40). | 48 // // intervals should now contain the single range [20, 40). |
49 // EXPECT_EQ(1, intervals.Size()); | 49 // EXPECT_EQ(1, intervals.Size()); |
50 // EXPECT_TRUE(intervals.Contains(Interval<int>(20, 40))); | 50 // EXPECT_TRUE(intervals.Contains(Interval<int>(20, 40))); |
51 | 51 |
52 #ifndef NET_QUIC_INTERVAL_SET_H_ | 52 #ifndef NET_QUIC_INTERVAL_SET_H_ |
53 #define NET_QUIC_INTERVAL_SET_H_ | 53 #define NET_QUIC_INTERVAL_SET_H_ |
54 | 54 |
55 #include <stddef.h> | 55 #include <stddef.h> |
| 56 |
56 #include <algorithm> | 57 #include <algorithm> |
57 #include <set> | 58 #include <set> |
58 #include <string> | 59 #include <string> |
59 #include <utility> | 60 #include <utility> |
60 #include <vector> | 61 #include <vector> |
61 | 62 |
62 #include "base/logging.h" | 63 #include "base/logging.h" |
63 #include "net/quic/interval.h" | 64 #include "net/quic/interval.h" |
64 | 65 |
65 namespace net { | 66 namespace net { |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 template <typename T> | 848 template <typename T> |
848 inline bool IntervalSet<T>::IntervalComparator::operator()( | 849 inline bool IntervalSet<T>::IntervalComparator::operator()( |
849 const Interval<T>& a, | 850 const Interval<T>& a, |
850 const Interval<T>& b) const { | 851 const Interval<T>& b) const { |
851 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())); |
852 } | 853 } |
853 | 854 |
854 } // namespace net | 855 } // namespace net |
855 | 856 |
856 #endif // NET_QUIC_INTERVAL_SET_H_ | 857 #endif // NET_QUIC_INTERVAL_SET_H_ |
OLD | NEW |