| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // intervals.Add(Interval<int>(15, 35)); | 42 // intervals.Add(Interval<int>(15, 35)); |
| 43 // // intervals has been coalesced. It now contains the single range [10,40). | 43 // // intervals has been coalesced. It now contains the single range [10,40). |
| 44 // EXPECT_EQ(1, intervals.Size()); | 44 // EXPECT_EQ(1, intervals.Size()); |
| 45 // EXPECT_TRUE(intervals.Contains(Interval<int>(10, 40))); | 45 // EXPECT_TRUE(intervals.Contains(Interval<int>(10, 40))); |
| 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_CORE_INTERVAL_SET_H_ |
| 53 #define NET_QUIC_INTERVAL_SET_H_ | 53 #define NET_QUIC_CORE_INTERVAL_SET_H_ |
| 54 | 54 |
| 55 #include <stddef.h> | 55 #include <stddef.h> |
| 56 | 56 |
| 57 #include <algorithm> | 57 #include <algorithm> |
| 58 #include <ostream> | 58 #include <ostream> |
| 59 #include <set> | 59 #include <set> |
| 60 #include <string> | 60 #include <string> |
| 61 #include <utility> | 61 #include <utility> |
| 62 #include <vector> | 62 #include <vector> |
| 63 | 63 |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 // Find() and Compact() methods. | 848 // Find() and Compact() methods. |
| 849 template <typename T> | 849 template <typename T> |
| 850 inline bool IntervalSet<T>::IntervalComparator::operator()( | 850 inline bool IntervalSet<T>::IntervalComparator::operator()( |
| 851 const Interval<T>& a, | 851 const Interval<T>& a, |
| 852 const Interval<T>& b) const { | 852 const Interval<T>& b) const { |
| 853 return (a.min() < b.min() || (a.min() == b.min() && a.max() > b.max())); | 853 return (a.min() < b.min() || (a.min() == b.min() && a.max() > b.max())); |
| 854 } | 854 } |
| 855 | 855 |
| 856 } // namespace net | 856 } // namespace net |
| 857 | 857 |
| 858 #endif // NET_QUIC_INTERVAL_SET_H_ | 858 #endif // NET_QUIC_CORE_INTERVAL_SET_H_ |
| OLD | NEW |