Class Comparators.AsListed<E>
- java.lang.Object
-
- eu.simuline.util.Comparators.AsListed<E>
-
- Type Parameters:
E- the type to be compared.
- All Implemented Interfaces:
java.io.Serializable,java.util.Comparator<E>
- Enclosing class:
- Comparators<E>
private static class Comparators.AsListed<E> extends java.lang.Object implements java.util.Comparator<E>, java.io.SerializableImplements an ordering given by the listseq. Elements not in the list are all minimal and pairwise equal with respect to this comparator. They are less than all elements in the list. The ordering on the list is ascending.CAUTION: This ordering is consistent with equals only if the elements of
seqare pairwise non-equal. If this condition is hurt, an elementamay satisfya>a. Even if this condition is satisfied, two elementsa,bnot inseqsatisfya=bwith respect to the ordering even if they are not equal with respect to the methodObject.equals(Object). Thus the ordering is consistent with equals only, if restricted to the elements ofseqplus one single object not inseq. This suffices to make the methodSet.add(Object)to work properly.The ordering is always total, i.e. either
a\le borb\le aholds. This is clear if both elements are inseqand also if one is not. Also the ordering is always transitive: Assumea\le borb\le c. Ifa\not\in seq, thena\le c. Ifb\not\in seqthen alsoa\not\in seq. Ifc\not\in seqthen alsob\not\in seq. So, if one of the elements is not inseq, transitivity holds. Otherwise, all elements are inseqand transitivity follows directly.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<E>seqprivate static longserialVersionUID
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(E obj1, E obj2)
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
seq
private final java.util.List<E> seq
-
-
Constructor Detail
-
AsListed
AsListed(java.util.List<E> seq)
-
-