| java.lang.Object org.cougaar.util.Sortings
Sortings | final public class Sortings (Code) | | Sortings is a set of utility methods which provide simple
and/or fixed sorting functionality to JDK Collections Framework.
The names of the methods are intended to echo CommonLisp functions
with similar functionality.
This is functionality which should be part of Java Collections framework
but is sadly missing.
|
Method Summary | |
public static Collection | sort(Collection collection, Comparator comparator, Mapping key) Similar functionality to java.util.Collections.sort, except with
several important extensions: the collection is sorted
into a new Collection (actually an ArrayList), all Collections are
sortable (not just Lists), and a key function may be specified, so
that the elements are compared based on the results of the key rather
than on the elements themselves.
If Collection is a List, and the key is null, this is equivalent to
something like Collections.sort(new ArrayList(collection), comparator);
Currently, the key mapping may be evaluated multiple times for each element. | public static Collection | sort(Collection collection, Comparator comparator) | public static Collection | sort(Collection collection, Mapping key) Like sort(collection, comparator, key) where comparator
is defined as using the Comparable interface. | public static Collection | sort(Collection collection) | public static Collection | sortInPlace(Collection collection, Comparator comparator, Mapping key) destructive version of sort(Collection,Comparator,key). | public static Collection | sortInPlace(Collection collection, Comparator comparator) destructive version of sort(Collection, Comparator). | public static Collection | sortInPlace(Collection collection, Mapping key) destructive version of sort(Collection, Mapping). | public static Collection | sortInPlace(Collection collection) destructive version of sort(Collection). |
sort | public static Collection sort(Collection collection, Comparator comparator, Mapping key)(Code) | | Similar functionality to java.util.Collections.sort, except with
several important extensions: the collection is sorted
into a new Collection (actually an ArrayList), all Collections are
sortable (not just Lists), and a key function may be specified, so
that the elements are compared based on the results of the key rather
than on the elements themselves.
If Collection is a List, and the key is null, this is equivalent to
something like Collections.sort(new ArrayList(collection), comparator);
Currently, the key mapping may be evaluated multiple times for each element.
A better implementation would evaluate the keys exactly once into an array
and then sort the keys and objects at the same time.
|
sort | public static Collection sort(Collection collection, Mapping key)(Code) | | Like sort(collection, comparator, key) where comparator
is defined as using the Comparable interface. Key may or may not
be null. If key is non-null, the resulting objects of applying the
key mapping must be Comparable.
|
sortInPlace | public static Collection sortInPlace(Collection collection, Comparator comparator, Mapping key)(Code) | | destructive version of sort(Collection,Comparator,key). collection must
implement the optional retainAll Collections framework method.
the (modified) collection |
sortInPlace | public static Collection sortInPlace(Collection collection, Comparator comparator)(Code) | | destructive version of sort(Collection, Comparator). collection must
implement the optional retainAll Collections framework method.
the (modified) collection |
sortInPlace | public static Collection sortInPlace(Collection collection, Mapping key)(Code) | | destructive version of sort(Collection, Mapping). collection must
implement the optional retainAll Collections framework method.
the (modified) collection |
sortInPlace | public static Collection sortInPlace(Collection collection)(Code) | | destructive version of sort(Collection). collection must
implement the optional retainAll Collections framework method.
the (modified) collection |
|
|