|
JUtil | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.cscott.jutil.Default
public abstract class Default
Default
contains one-off or 'standard, no-frills'
implementations of simple Iterator
s,
Collection
s, and Comparator
s.
Nested Class Summary | |
---|---|
static class |
Default.PairList<A,B>
Pairs, implemented as a List . |
Field Summary | |
---|---|
static Comparator |
comparator
A Comparator for objects that implement
Comparable (checked dynamically at run-time). |
static SortedMap |
EMPTY_MAP
Deprecated. Use Collections.EMPTY_MAP |
static MultiMap |
EMPTY_MULTIMAP
An empty multi-map. |
static SortedSet |
EMPTY_SET
Deprecated. Use Collections.EMPTY_SET |
static Iterator |
nullIterator
An Iterator over the empty set. |
Constructor Summary | |
---|---|
Default()
|
Method Summary | ||
---|---|---|
static
|
comparator()
A Comparator for objects that implement
Comparable (checked dynamically at run-time). |
|
static
|
EMPTY_LIST()
Deprecated. Use Collections.emptyList() |
|
static
|
EMPTY_MAP()
Deprecated. Use Collections.emptyMap() |
|
static
|
EMPTY_MULTIMAP()
An empty multi-map, parameterized to play nicely with Java's type system. |
|
static
|
EMPTY_SET()
Deprecated. Use Collections.emptySet() |
|
static
|
entry(K key,
V value)
A pair constructor method more appropriate for Set
views of Map s and MultiMap s. |
|
static
|
nullIterator()
An Iterator over the empty set, parameterized to
play nicely with Java's type system. |
|
static
|
pair(A left,
B right)
A pair constructor method. |
|
static
|
singletonIterator(E o)
An Iterator over a singleton set. |
|
static
|
unmodifiableCollection(Collection<? extends A> cc)
Improved unmodifiableCollection() class that
helps w/ covariant subtyping. |
|
static
|
unmodifiableIterator(Iterator<E> i)
An unmodifiable version of the given iterator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Comparator comparator
Comparator
for objects that implement
Comparable
(checked dynamically at run-time).
public static final Iterator nullIterator
Iterator
over the empty set.
public static final SortedSet EMPTY_SET
public static final SortedMap EMPTY_MAP
Collections
in
Java 1.2.
public static final MultiMap EMPTY_MULTIMAP
Constructor Detail |
---|
public Default()
Method Detail |
---|
public static final <T extends Comparable<T>> Comparator<T> comparator()
Comparator
for objects that implement
Comparable
(checked dynamically at run-time).
This version is parameterized to play nicely with Java's
type system.
public static final <E> Iterator<E> nullIterator()
Iterator
over the empty set, parameterized to
play nicely with Java's type system.
public static final <E> Iterator<E> singletonIterator(E o)
Iterator
over a singleton set.
public static final <E> Iterator<E> unmodifiableIterator(Iterator<E> i)
public static final <E> SortedSet<E> EMPTY_SET()
public static final <E> List<E> EMPTY_LIST()
public static final <K,V> SortedMap<K,V> EMPTY_MAP()
public static final <K,V> MultiMap<K,V> EMPTY_MULTIMAP()
public static <A> Collection<A> unmodifiableCollection(Collection<? extends A> cc)
unmodifiableCollection()
class that
helps w/ covariant subtyping.
public static <A,B> Default.PairList<A,B> pair(A left, B right)
hashCode()
and equals()
"properly" so they can be used as keys
in hashtables and etc. They are implemented as mutable lists of
fixed size 2.
public static <K,V> Map.Entry<K,V> entry(K key, V value)
Set
views of Map
s and MultiMap
s.
The returned object is an instance of Map.Entry
;
the only (real) difference from the pairs returned by
Default.pair()
is the definition of
hashCode()
, which corresponds to Map.Entry
(being key.hashCode() ^ value.hashCode()
) rather
than Default.PairList
(which would be
31*(31+key.hashCode())+value.hashCode()
). This is
an annoying distinction; I wish the JDK API authors had made
these consistent. The Map.Entry
returned is immutable.
|
JUtil | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |