yangxu998 / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Predicates lessThan, greaterThan etc #638

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
(Also useful referenced from #477)

I reckon there should be the following methods in Predicates:

<T extends Comparable<T>> Predicate<T> lessThan(T value);
<T extends Comparable<T>> Predicate<T> greaterThan(T value);

I'm in three minds about 

<T extends Comparable<T>> Predicate<T> lessThanOrEqual(T value);
<T extends Comparable<T>> Predicate<T> greaterThanOrEqual(T value);

* Should they exist? and if they did, would they
* be another implementation that matches true if compareTo() == 0
* a composition: or((lessThan(value), equalTo(value))

Also, we should add the Comparator based methods:

<T> Predicate<T> lessThan(T value, Comparator<T> c);
<T> Predicate<T> greaterThan(T value, Comparator<T> c);

Original issue reported on code.google.com by stephen....@gmail.com on 2 Jun 2011 at 5:08

GoogleCodeExporter commented 9 years ago
This is part of the Ranges, which might appear in r10. However there are some 
discussions about what a Range should and shouldn't be, or support. I hope that 
if Ranges won't end up in r10, that this methods will get in at least in 
Predicates.

Original comment by gscerbak@gmail.com on 2 Jun 2011 at 8:39

GoogleCodeExporter commented 9 years ago
lessThanOrEqual / greaterThanOrEqual can also be implemented as 
not(greaterThan(value)) and not(lessThan(value))

Original comment by raymond....@gmail.com on 2 Jun 2011 at 9:58

GoogleCodeExporter commented 9 years ago
I think sometimes the *OrEqual read better and make more sense in a given 
domain.

Original comment by gscerbak@gmail.com on 2 Jun 2011 at 11:11

GoogleCodeExporter commented 9 years ago
If these methods were in Ordering<T> they would not need the extra overload: It 
would be myOrdering.greaterThan(value) or Ordering.natural().greaterThan(value)

Original comment by fin...@gmail.com on 2 Jun 2011 at 11:30

GoogleCodeExporter commented 9 years ago
Ranges are already in for r10 
(http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/colle
ct/Ranges.html).

Original comment by cgdec...@gmail.com on 2 Jun 2011 at 1:02

GoogleCodeExporter commented 9 years ago
Is there a release page for r10 (rather than pointing to a source revision :p)?

Also, I can't find information about how a class exits @Beta; is there a page? 
Are Ranges likely to be @Beta for Release 10? Finalised by 11...? 

Original comment by stephen....@gmail.com on 7 Jun 2011 at 1:04

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 18 Jul 2011 at 3:34

GoogleCodeExporter commented 9 years ago
Preliminary r10 notes here: 
http://code.google.com/p/guava-libraries/wiki/Release10

Ranges are in.  I doubt they'll be finalized by release 11, in part because we 
haven't used them enough internally to decide whether the main Range API is 
right and in part because there are related classes (ContiguousSet, for 
example) that we're still actively fiddling with.

Original comment by cpov...@google.com on 1 Sep 2011 at 10:17

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:09