|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jpaul.DataStructs.SetFacts
public final class SetFacts
SetFacts
contains common set factories. For
each kind of set factory, we have a corresponding static method.
Note: some old set factories that used to exist as separate
classes are now static inner classes of this class. They are
provided mostly to simplify porting old code (programmers only have
to change a few import
statements).
Nested Class Summary | |
---|---|
static class |
SetFacts.COWSetFactory<E>
Deprecated. As of jpaul 2.2, use cow(SetFactory) instead. |
static class |
SetFacts.HashSetFactory<E>
Deprecated. As of jpaul 2.2, use hash() instead. |
static class |
SetFacts.TreeSetFactory<E>
Deprecated. As of jpaul 2.2, use tree(Comparator) instead. |
Method Summary | ||
---|---|---|
static
|
cow(SetFactory<E> underSetFact)
Returns a set factory that generates "copy-on-write" (COW) sets. |
|
static
|
hash()
Returns a set factory that generates LinkedHashSet s. |
|
static
|
mapBased(MapFactory<E,java.lang.Object> mapFact)
Returns a set factory that generates map-backed sets. |
|
static
|
noCompTree()
Returns a set factory that generates sets backed by NoCompTreeMap s. |
|
static
|
tree(java.util.Comparator<E> comp)
Returns a set factory that generates TreeSet s. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <E> SetFactory<E> hash()
LinkedHashSet
s. LinkedHashSet
s are
great for applications that use a few large sets; in addition,
they provide predictable iteration order (identical to the
insertion order). A LinkedHashSet
is only
slightly slower than a HashSet
(iteration is
actually faster: linear in the actual size, independent of the
capacity). Therefore, in the interest o simplicity, instead
of offering a factory for plain HashSet
s, and a
factory for LinkedHashSet
s, jpaul
offers only the latter.
public static <E> SetFactory<E> tree(java.util.Comparator<E> comp)
TreeSet
s.
TreeSet
s are great for applications that use many
small sets.
public static <E> SetFactory<E> cow(SetFactory<E> underSetFact)
The internal representation of a COW set maintains a "sharing" counter to identify cases when the representation is not shared with anyone (and hence, no cloning is necessary before a mutation).
Cloning a COW set is a constant time operation. COW sets are good when it is hard to determine statically whether a clone of a set will be mutated: they delay the real cloning until the first mutation (if any).
underSetFact
- Set factory for generating the sets used
in the representation of the COW sets.public static <E> SetFactory<E> mapBased(MapFactory<E,java.lang.Object> mapFact)
null
keys, so virtually any map
factory is good as argument.
mapFact
- Factory for the maps used in the representation
of the generated sets.public static <E> SetFactory<E> noCompTree()
NoCompTreeMap
s. NoCompTreeMap
is a binary
tree-backed map that does not require a user-defined Comparator
between keys. This set
factory is good for applications that use many small trees and
when a total order Comparator
is hard to
write.
mapBased(jpaul.DataStructs.MapFactory)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |