|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--harpoon.Util.Collections.CollectionFactory | +--harpoon.Util.Collections.ListFactory
ListFactory
is a List
generator.
Subclasses should implement constructions of specific types of
List
s. ListFactory
also has a set of
static helper methods for building List
objects.
Constructor Summary | |
ListFactory()
Creates a ListFactory . |
Method Summary | |
static List |
concatenate(List lists)
Creates and returns an unmodifiable List view of
the list made from connecting lists together in
order. |
static List |
concatenate(List[] lists)
Creates and returns an unmodifiable List view of
the list made from connecting lists together in
order. |
Collection |
makeCollection(Collection c)
Generates a new, mutable Collection , using the
elements of c as a template for its initial
contents. |
Collection |
makeCollection(int initCapacity)
Generates a new, mutable, empty Collection , using
initialCapacity as a hint to use for the capacity
for the produced Collection . |
List |
makeList()
Generates a new, mutable, empty List . |
abstract List |
makeList(Collection c)
Generates a new mutable List , using the elements
of c as a template for its initial contents. |
List |
makeList(int initialCapacity)
Generates a new, mutable, empty List , using
initialCapacity as a hint to use for the capacity
for the produced List . |
static List |
singleton(Object o)
Creates and returns an immutable List of one element. |
Methods inherited from class harpoon.Util.Collections.CollectionFactory |
makeCollection |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ListFactory()
ListFactory
.
Method Detail |
public final Collection makeCollection(int initCapacity)
CollectionFactory
Collection
, using
initialCapacity
as a hint to use for the capacity
for the produced Collection
.
makeCollection
in class CollectionFactory
public final Collection makeCollection(Collection c)
CollectionFactory
Collection
, using the
elements of c
as a template for its initial
contents. Note that the Collection
returned is
not a view of c
, but rather a snapshot;
changes to c
are not reflected in the returned
Collection
.
makeCollection
in class CollectionFactory
public final List makeList()
List
.
public List makeList(int initialCapacity)
List
, using
initialCapacity
as a hint to use for the capacity
for the produced List
.
public abstract List makeList(Collection c)
List
, using the elements
of c
as a template for its initial contents.
public static List concatenate(List lists)
List
view of
the list made from connecting lists
together in
order.
lists
is a
List
of List
s.
let l0 = (List) lists.get(0) l1 = (List) lists.get(1) ... ln = (List) lists.get(n) where n is lists.size()-1 returns a list view [ l0.get(0) , l0.get(1), ... , l0.get(l0.size()-1), l1.get(0) , l1.get(1), ... , l1.get(l1.size()-1), ... ln.get(0) , ln.get(1), ... , ln.get(ln.size()-1) ]Note that not only changes to the elements of
lists
are reflected in the returned
List
, but even changes to lists
itself (adding or removing lists) are also reflected.
public static List concatenate(List[] lists)
List
view of
the list made from connecting lists
together in
order.
let l0 = lists[0] l1 = lists[1] ... ln = lists[n] where n is lists.length-1 returns a list view [ l0.get(0) , l0.get(1), ... , l0.get(l0.size()-1), l1.get(0) , l1.get(1), ... , l1.get(l1.size()-1), ... ln.get(0) , ln.get(1), ... , ln.get(ln.size()-1) ]Note that changes to the elements of
lists
are
reflected in this
.
public static List singleton(Object o)
List
of one element.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |