| 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 // An Interval<T> is a data structure used to represent a contiguous, mutable | 5 // An Interval<T> is a data structure used to represent a contiguous, mutable |
| 6 // range over an ordered type T. Supported operations include testing a value to | 6 // range over an ordered type T. Supported operations include testing a value to |
| 7 // see whether it is included in the interval, comparing two intervals, and | 7 // see whether it is included in the interval, comparing two intervals, and |
| 8 // performing their union, intersection, and difference. For the purposes of | 8 // performing their union, intersection, and difference. For the purposes of |
| 9 // this library, an "ordered type" is any type that induces a total order on its | 9 // this library, an "ordered type" is any type that induces a total order on its |
| 10 // values via its less-than operator (operator<()). Examples of such types are | 10 // values via its less-than operator (operator<()). Examples of such types are |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // EXPECT_TRUE(r1.Intersects(r2)); | 50 // EXPECT_TRUE(r1.Intersects(r2)); |
| 51 // EXPECT_FALSE(r1.Contains(r2)); | 51 // EXPECT_FALSE(r1.Contains(r2)); |
| 52 // EXPECT_TRUE(r1.IntersectWith(r2)); // Mutates r1. | 52 // EXPECT_TRUE(r1.IntersectWith(r2)); // Mutates r1. |
| 53 // EXPECT_EQ(Interval<int>(50, 100), r1); // r1 is now [50, 100). | 53 // EXPECT_EQ(Interval<int>(50, 100), r1); // r1 is now [50, 100). |
| 54 // | 54 // |
| 55 // Interval<int> r3(1000, 2000); // The interval [1000, 2000). | 55 // Interval<int> r3(1000, 2000); // The interval [1000, 2000). |
| 56 // EXPECT_TRUE(r1.IntersectWith(r3)); // Mutates r1. | 56 // EXPECT_TRUE(r1.IntersectWith(r3)); // Mutates r1. |
| 57 // EXPECT_TRUE(r1.Empty()); // Now r1 is empty. | 57 // EXPECT_TRUE(r1.Empty()); // Now r1 is empty. |
| 58 // EXPECT_FALSE(r1.Contains(r1.min())); // e.g. doesn't contain its own min. | 58 // EXPECT_FALSE(r1.Contains(r1.min())); // e.g. doesn't contain its own min. |
| 59 | 59 |
| 60 #ifndef NET_QUIC_INTERVAL_H_ | 60 #ifndef NET_QUIC_CORE_INTERVAL_H_ |
| 61 #define NET_QUIC_INTERVAL_H_ | 61 #define NET_QUIC_CORE_INTERVAL_H_ |
| 62 | 62 |
| 63 #include <stddef.h> | 63 #include <stddef.h> |
| 64 | 64 |
| 65 #include <algorithm> | 65 #include <algorithm> |
| 66 #include <functional> | 66 #include <functional> |
| 67 #include <ostream> | 67 #include <ostream> |
| 68 #include <string> | 68 #include <string> |
| 69 #include <utility> | 69 #include <utility> |
| 70 #include <vector> | 70 #include <vector> |
| 71 | 71 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 // [------ i --------) | 292 // [------ i --------) |
| 293 // Intersection is <this>, so difference yields the empty interval. | 293 // Intersection is <this>, so difference yields the empty interval. |
| 294 return true; | 294 return true; |
| 295 } | 295 } |
| 296 *lo = *this; // No intersection. | 296 *lo = *this; // No intersection. |
| 297 return false; | 297 return false; |
| 298 } | 298 } |
| 299 | 299 |
| 300 } // namespace net | 300 } // namespace net |
| 301 | 301 |
| 302 #endif // NET_QUIC_INTERVAL_H_ | 302 #endif // NET_QUIC_CORE_INTERVAL_H_ |
| OLD | NEW |