org.jjoost.util.filters
Class AcceptUniqueDescendingSequence<V>

java.lang.Object
  extended by org.jjoost.util.filters.AcceptUniqueDescendingSequence<V>
All Implemented Interfaces:
FilterPartialOrder<V>

public class AcceptUniqueDescendingSequence<V>
extends java.lang.Object
implements FilterPartialOrder<V>

A partial order filter which will accept a value only if it has never previously seen a value less than or equal to the value being tested; in an ordered set this results in unique values being efficiently obtained if applied in an descending order visit of some kind; it is a one shot filter, however, given the state stored.

Author:
b.elliottsmith

Constructor Summary
AcceptUniqueDescendingSequence()
           
 
Method Summary
 boolean accept(V next, java.util.Comparator<? super V> cmp)
          Return true iff this filter and comparator combination accept the provided value
static
<V> AcceptUniqueDescendingSequence<V>
get()
          Returns a partial order filter which will accept a value only if it has never previously seen a value less than or equal to the value being tested; in an ordered set this results in unique values being efficiently obtained if applied in an descending order visit of some kind; it is a one shot filter, however, given the state stored.
 boolean mayAcceptBetween(V lb, boolean lbInclusive, V ub, boolean ubInclusive, java.util.Comparator<? super V> cmp)
          Returns true if there exists (in the total order defined by the comparator, not necessarily in any concrete data set this is being applied to) a value between lb and ub that this filter may accept.
 boolean mayRejectBetween(V lb, boolean lbInclusive, V ub, boolean ubInclusive, java.util.Comparator<? super V> cmp)
          Returns true if there exists (in the total order defined by the comparator, not necessarily in any concrete data set this is being applied to) a value between lb and ub that this filter may reject.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AcceptUniqueDescendingSequence

public AcceptUniqueDescendingSequence()
Method Detail

accept

public boolean accept(V next,
                      java.util.Comparator<? super V> cmp)
Description copied from interface: FilterPartialOrder
Return true iff this filter and comparator combination accept the provided value

Specified by:
accept in interface FilterPartialOrder<V>
Parameters:
next - the value to check
cmp - the partial order
Returns:
true, if accepts

mayAcceptBetween

public boolean mayAcceptBetween(V lb,
                                boolean lbInclusive,
                                V ub,
                                boolean ubInclusive,
                                java.util.Comparator<? super V> cmp)
Description copied from interface: FilterPartialOrder
Returns true if there exists (in the total order defined by the comparator, not necessarily in any concrete data set this is being applied to) a value between lb and ub that this filter may accept. This method may return true if there is no such value, at the cost of more expensive execution but valid behaviour, however it cannot return false if there is such a value without breaking functionality. null values should be seen as both +/- infinity, i.e. containsBetween(null, o) should return containsBefore(o) and containsBetween(o, null) should return containsAfter(o) containsBetween should take arguments IN ORDER, i.e. o1 <= o2; behaviour where o2 < o1 is undefined.

Specified by:
mayAcceptBetween in interface FilterPartialOrder<V>
Parameters:
lb - the lower bound of the range to check
lbInclusive - if the lower bound should be taken as inclusive
ub - the upper bound of the range to check
ubInclusive - if the upper bound should be taken as inclusive
cmp - the partial order
Returns:
true, if there may exists a value V such that lb <(/<=) V <(/<=) ub and accept(V, cmp) == true

mayRejectBetween

public boolean mayRejectBetween(V lb,
                                boolean lbInclusive,
                                V ub,
                                boolean ubInclusive,
                                java.util.Comparator<? super V> cmp)
Description copied from interface: FilterPartialOrder
Returns true if there exists (in the total order defined by the comparator, not necessarily in any concrete data set this is being applied to) a value between lb and ub that this filter may reject. This method may return true if there is no such value at the cost of more expensive execution but valid behaviour, however it cannot return false if there is such a value without breaking functionality. null values should be seen as both +/- infinity, i.e. containsBetween(null, o) should return containsBefore(o) and containsBetween(o, null) should return containsAfter(o) containsBetween should take arguments IN ORDER, i.e. o1 <= o2; behaviour where o2 < o1 is undefined.

Specified by:
mayRejectBetween in interface FilterPartialOrder<V>
Parameters:
lb - the lower bound of the range to check
lbInclusive - if the lower bound should be taken as inclusive
ub - the upper bound of the range to check
ubInclusive - if the upper bound should be taken as inclusive
cmp - the partial order
Returns:
true, if there may exists a value V such that lb <(/<=) V <(/<=) ub and accept(V, cmp) == false

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

get

public static <V> AcceptUniqueDescendingSequence<V> get()
Returns a partial order filter which will accept a value only if it has never previously seen a value less than or equal to the value being tested; in an ordered set this results in unique values being efficiently obtained if applied in an descending order visit of some kind; it is a one shot filter, however, given the state stored.

Returns:
a filter accepting a unique sequence if applied in descending order