Commit 04d50002 authored by avi's avatar avi Committed by Commit bot

Remove QUIC's Interval::difference(vector<Interval*>*).

It's unused.

BUG=555865
R=bnc@chromium.org

Review-Url: https://codereview.chromium.org/2339223003
Cr-Commit-Position: refs/heads/master@{#418890}
parent cddda4b3
......@@ -157,19 +157,6 @@ class Interval {
// to represent that interval, and returns true iff *this was modified.
bool SpanningUnion(const Interval& i);
// Determines the difference between two intervals by finding all points that
// are contained in *this but not in i, coalesces those points into the
// largest possible contiguous intervals, and appends those intervals to the
// *difference vector. Intuitively this can be thought of as "erasing" i from
// *this. This will either completely erase *this (leaving nothing behind),
// partially erase some of *this from the left or right side (leaving some
// residual behind), or erase a hole in the middle of *this (leaving behind an
// interval on either side). Therefore, 0, 1, or 2 intervals will be appended
// to *difference. The method returns true iff the intersection of *this and i
// is non-empty. The caller owns the vector and the Interval* pointers
// inside it. The difference vector is required to be non-null.
bool Difference(const Interval& i, std::vector<Interval*>* difference) const;
// Determines the difference between two intervals as in
// Difference(Interval&, vector*), but stores the results directly in out
// parameters rather than dynamically allocating an Interval* and appending
......@@ -264,53 +251,6 @@ bool Interval<T>::SpanningUnion(const Interval& i) {
return modified;
}
template <typename T>
bool Interval<T>::Difference(const Interval& i,
std::vector<Interval*>* difference) const {
if (Empty()) {
// <empty> - <i> = <empty>
return false;
}
if (i.Empty()) {
// <this> - <empty> = <this>
difference->push_back(new Interval(*this));
return false;
}
if (min() < i.max() && min() >= i.min() && max() > i.max()) {
// [------ this ------)
// [------ i ------)
// [-- result ---)
difference->push_back(new Interval(i.max(), max()));
return true;
}
if (max() > i.min() && max() <= i.max() && min() < i.min()) {
// [------ this ------)
// [------ i ------)
// [- result -)
difference->push_back(new Interval(min(), i.min()));
return true;
}
if (min() < i.min() && max() > i.max()) {
// [------- this --------)
// [---- i ----)
// [ R1 ) [ R2 )
// There are two results: R1 and R2.
difference->push_back(new Interval(min(), i.min()));
difference->push_back(new Interval(i.max(), max()));
return true;
}
if (min() >= i.min() && max() <= i.max()) {
// [--- this ---)
// [------ i --------)
// Intersection is <this>, so difference yields the empty interval.
// Nothing is appended to *difference.
return true;
}
// No intersection. Append <this>.
difference->push_back(new Interval(*this));
return false;
}
template <typename T>
bool Interval<T>::Difference(const Interval& i,
Interval* lo,
......
......@@ -12,7 +12,6 @@
#include "net/quic/core/interval.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "net/test/gtest_util.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -205,22 +204,6 @@ TEST_F(IntervalTest, CoveringOps) {
EXPECT_TRUE(!d.Contains(201));
// Difference:
vector<Interval<int64_t>*> diff;
EXPECT_TRUE(!d.Difference(empty, &diff));
EXPECT_EQ(1u, diff.size());
EXPECT_EQ(100u, diff[0]->min());
EXPECT_EQ(200u, diff[0]->max());
base::STLDeleteElements(&diff);
EXPECT_TRUE(!empty.Difference(d, &diff) && diff.empty());
EXPECT_TRUE(d.Difference(d, &diff) && diff.empty());
EXPECT_TRUE(!d.Difference(d1, &diff));
EXPECT_EQ(1u, diff.size());
EXPECT_EQ(100u, diff[0]->min());
EXPECT_EQ(200u, diff[0]->max());
base::STLDeleteElements(&diff);
Interval<int64_t> lo;
Interval<int64_t> hi;
......@@ -228,69 +211,36 @@ TEST_F(IntervalTest, CoveringOps) {
EXPECT_TRUE(lo.Empty());
EXPECT_EQ(110u, hi.min());
EXPECT_EQ(200u, hi.max());
EXPECT_TRUE(d.Difference(d2, &diff));
EXPECT_EQ(1u, diff.size());
EXPECT_EQ(110u, diff[0]->min());
EXPECT_EQ(200u, diff[0]->max());
base::STLDeleteElements(&diff);
EXPECT_TRUE(d.Difference(d3, &lo, &hi));
EXPECT_EQ(100u, lo.min());
EXPECT_EQ(110u, lo.max());
EXPECT_EQ(180u, hi.min());
EXPECT_EQ(200u, hi.max());
EXPECT_TRUE(d.Difference(d3, &diff));
EXPECT_EQ(2u, diff.size());
EXPECT_EQ(100u, diff[0]->min());
EXPECT_EQ(110u, diff[0]->max());
EXPECT_EQ(180u, diff[1]->min());
EXPECT_EQ(200u, diff[1]->max());
base::STLDeleteElements(&diff);
EXPECT_TRUE(d.Difference(d4, &lo, &hi));
EXPECT_EQ(100u, lo.min());
EXPECT_EQ(180u, lo.max());
EXPECT_TRUE(hi.Empty());
EXPECT_TRUE(d.Difference(d4, &diff));
EXPECT_EQ(1u, diff.size());
EXPECT_EQ(100u, diff[0]->min());
EXPECT_EQ(180u, diff[0]->max());
base::STLDeleteElements(&diff);
EXPECT_FALSE(d.Difference(d5, &lo, &hi));
EXPECT_EQ(100u, lo.min());
EXPECT_EQ(200u, lo.max());
EXPECT_TRUE(hi.Empty());
EXPECT_FALSE(d.Difference(d5, &diff));
EXPECT_EQ(1u, diff.size());
EXPECT_EQ(100u, diff[0]->min());
EXPECT_EQ(200u, diff[0]->max());
base::STLDeleteElements(&diff);
EXPECT_TRUE(d.Difference(d6, &lo, &hi));
EXPECT_TRUE(lo.Empty());
EXPECT_EQ(150u, hi.min());
EXPECT_EQ(200u, hi.max());
EXPECT_TRUE(d.Difference(d6, &diff));
EXPECT_EQ(1u, diff.size());
EXPECT_EQ(150u, diff[0]->min());
EXPECT_EQ(200u, diff[0]->max());
base::STLDeleteElements(&diff);
EXPECT_TRUE(d.Difference(d7, &lo, &hi));
EXPECT_EQ(100u, lo.min());
EXPECT_EQ(150u, lo.max());
EXPECT_TRUE(hi.Empty());
EXPECT_TRUE(d.Difference(d7, &diff));
EXPECT_EQ(1u, diff.size());
EXPECT_EQ(100u, diff[0]->min());
EXPECT_EQ(150u, diff[0]->max());
base::STLDeleteElements(&diff);
EXPECT_TRUE(d.Difference(d8, &lo, &hi));
EXPECT_TRUE(lo.Empty());
EXPECT_TRUE(hi.Empty());
EXPECT_TRUE(d.Difference(d8, &diff) && diff.empty());
}
TEST_F(IntervalTest, Length) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment