> On Feb. 17, 2014, 9:24 p.m., Ben Mahler wrote: > > 3rdparty/libprocess/3rdparty/stout/tests/interval_tests.cpp, lines 167-168 > > <https://reviews.apache.org/r/18093/diff/3/?file=487340#file487340line167> > > > > Can these be called lower() and upper()?
That's gonna hide the lower() and upper() in discrete_interval, on which type traits depend. > On Feb. 17, 2014, 9:24 p.m., Ben Mahler wrote: > > 3rdparty/libprocess/3rdparty/stout/tests/interval_tests.cpp, line 166 > > <https://reviews.apache.org/r/18093/diff/3/?file=487340#file487340line166> > > > > Is there support for iterating over an individual interval as well? Or > > did you want to hide that for the reasons you mentioned earlier with > > respect to the interval being potentially very large? > > > > If there's support, perhaps we should show how to do it in the tests: > > > > foreach (int i, interval) { > > ... > > } In fact, foreach only supports one type of iteration (element or segment). I prefer segment iteration because element iteration is dangerous if an interval is very large. If a user wants to do element iteration, it has to be explicit (see IntervalTest.ElementIteration). > On Feb. 17, 2014, 9:24 p.m., Ben Mahler wrote: > > 3rdparty/libprocess/3rdparty/stout/tests/interval_tests.cpp, lines 170-182 > > <https://reviews.apache.org/r/18093/diff/3/?file=487340#file487340line170> > > > > I'm trying to think of how a caller would interact with this API. It > > seems a little cumbersome to work with, since you need to deal with all the > > permutations of left and right bound types, right? > > > > Is it possible to standardize the bounds as [lower, upper) as is done > > in the standard library? > > > > int lower = interval.lower(); // Returns inclusive lower. > > int upper = interval.upper(); // Returns exclusive upper. Hum... Are you asking for an iterator for Interval? To get the inclusive left bound, returns *begin(); To get the exclusive right bound, returns *end(); And, we can also do: foreach (const T& value, interval) { ... } - Jie ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/18093/#review34665 ----------------------------------------------------------- On Feb. 17, 2014, 1:46 a.m., Jie Yu wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/18093/ > ----------------------------------------------------------- > > (Updated Feb. 17, 2014, 1:46 a.m.) > > > Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone. > > > Bugs: MESOS-993 > https://issues.apache.org/jira/browse/MESOS-993 > > > Repository: mesos-git > > > Description > ------- > > See summary. > > > Diffs > ----- > > 3rdparty/libprocess/3rdparty/Makefile.am 51b118c > 3rdparty/libprocess/3rdparty/stout/Makefile.am 5d5a760 > 3rdparty/libprocess/3rdparty/stout/include/stout/interval.hpp PRE-CREATION > 3rdparty/libprocess/3rdparty/stout/tests/interval_tests.cpp PRE-CREATION > > Diff: https://reviews.apache.org/r/18093/diff/ > > > Testing > ------- > > make check > > repeat 1000 times for the IntervalTest > > Repeating all tests (iteration 100) . . . > > Note: Google Test filter = *Interval* > [==========] Running 7 tests from 1 test case. > [----------] Global test environment set-up. > [----------] 7 tests from IntervalTest > [ RUN ] IntervalTest.Interval > [ OK ] IntervalTest.Interval (0 ms) > [ RUN ] IntervalTest.Addition > [ OK ] IntervalTest.Addition (0 ms) > [ RUN ] IntervalTest.Subtraction > [ OK ] IntervalTest.Subtraction (0 ms) > [ RUN ] IntervalTest.Intersection > [ OK ] IntervalTest.Intersection (0 ms) > [ RUN ] IntervalTest.LargeInterval > [ OK ] IntervalTest.LargeInterval (0 ms) > [ RUN ] IntervalTest.ElementIteration > [ OK ] IntervalTest.ElementIteration (0 ms) > [ RUN ] IntervalTest.IntervalIteration > [ OK ] IntervalTest.IntervalIteration (0 ms) > [----------] 7 tests from IntervalTest (0 ms total) > > [----------] Global test environment tear-down > [==========] 7 tests from 1 test case ran. (0 ms total) > [ PASSED ] 7 tests. > > > Thanks, > > Jie Yu > >
