public class CollectionsTool extends Object
| Constructor and Description |
|---|
CollectionsTool() |
| Modifier and Type | Method and Description |
|---|---|
<E> Collection<E> |
disjunction(Collection<E> a,
Collection<E> b)
Returns a
Collection containing the exclusive disjunction (symmetric difference) of the given
Collections. |
<E> List<E> |
getArrayList()
Create and return a new
ArrayList, an unbounded list with constant access time and good performance for
most additions at the end of the list, but which performs poorly when deleting items, when inserting a new item
in the list and when appending a new item requires resizing the allocated space. |
<E> BlockingQueue<E> |
getBlockingQueue()
Create and return a new
BlockingQueue, an unbounded queue that additionally supports operations that wait
for the queue to become non-empty when retrieving an element. |
<E> List<E> |
getLinkedList()
Create and return a new
LinkedList, optimized for insertion and deletion of items, and for sequential
iteration over the items, but not for quick access to random positions in the list. |
<K,V> Map<K,V> |
getMap()
Create and return a new
Map, providing good speed for insertion, retrieval and deletion of items, but
with no guarantees on the order of the map. |
<K,V> Map<K,V> |
getOrderedMap()
Create and return a new
Map, which ensures that iterating the map will always return the entries in the
same order as they were added. |
<E> Set<E> |
getOrderedSet()
Create and return a new
Set, which ensures that iterating the set will always return the entries in the
same order as they were added. |
<E extends Comparable<E>> |
getPriorityQueue()
Create and return a new
Queue, which instead of the FIFO ordering uses the natural order of the items
added to the queue, so that the retrieved item is always the lowest one. |
<E> Queue<E> |
getQueue()
Create and return a new
Queue, an unbounded list where items are ordered in a FIFO (first-in-first-out)
manner. |
<E> Set<E> |
getSet()
Create and return a new
Set, providing good speed for insertion, retrieval and deletion of items, but
with no guarantees on the order of the set. |
<K extends Comparable<K>,V> |
getSortedMap()
Create and return a new
SortedMap, which ensures that iterating the map will always return the entries in
the natural order of the keys. |
<E extends Comparable<E>> |
getSortedSet()
Create and return a new
SortedSet, which ensures that iterating the set will always return the entries in
the natural order of the items. |
<E> Collection<E> |
intersection(Collection<E> a,
Collection<E> b)
Returns a
Collection containing the intersection of the given Collections. |
<E> boolean |
reverse(List<E> input)
Reverse the order of the elements within a list, so that the last element is moved to the beginning of the list,
the next-to-last element to the second position, and so on.
|
<E extends Comparable<E>> |
sort(List<E> input)
Sort the elements within a list according to their natural order.
|
<E> Collection<E> |
union(Collection<E> a,
Collection<E> b)
Returns a
Collection containing the union of the given Collections. |
<E> Collection<E> |
unmodifiable(Collection<E> input)
Returns an unmodifiable view of the specified collection.
|
<E> List<E> |
unmodifiable(List<E> input)
Returns an unmodifiable view of the specified list.
|
<K,V> Map<K,V> |
unmodifiable(Map<K,V> input)
Returns an unmodifiable view of the specified map.
|
<E> Set<E> |
unmodifiable(Set<E> input)
Returns an unmodifiable view of the specified set.
|
public <E> List<E> getArrayList()
ArrayList, an unbounded list with constant access time and good performance for
most additions at the end of the list, but which performs poorly when deleting items, when inserting a new item
in the list and when appending a new item requires resizing the allocated space.E - the type of the elements in the listArrayListpublic <E> List<E> getLinkedList()
LinkedList, optimized for insertion and deletion of items, and for sequential
iteration over the items, but not for quick access to random positions in the list.E - the type of the elements in the listLinkedListpublic <K,V> Map<K,V> getMap()
Map, providing good speed for insertion, retrieval and deletion of items, but
with no guarantees on the order of the map.K - the type of keys maintained by this mapV - the type of mapped valuesHashMappublic <K extends Comparable<K>,V> SortedMap<K,V> getSortedMap()
SortedMap, which ensures that iterating the map will always return the entries in
the natural order of the keys.K - the type of keys maintained by this mapV - the type of mapped valuesTreeMappublic <K,V> Map<K,V> getOrderedMap()
Map, which ensures that iterating the map will always return the entries in the
same order as they were added.K - the type of keys maintained by this mapV - the type of mapped valuesLinkedHashMappublic <E> Set<E> getSet()
Set, providing good speed for insertion, retrieval and deletion of items, but
with no guarantees on the order of the set.E - the type of the elements in the setHashSetpublic <E extends Comparable<E>> SortedSet<E> getSortedSet()
SortedSet, which ensures that iterating the set will always return the entries in
the natural order of the items.E - the type of the elements in the setTreeSetpublic <E> Set<E> getOrderedSet()
Set, which ensures that iterating the set will always return the entries in the
same order as they were added.E - the type of the elements in the setLinkedHashSetpublic <E> Queue<E> getQueue()
Queue, an unbounded list where items are ordered in a FIFO (first-in-first-out)
manner.E - the type of the elements in the queueLinkedListpublic <E> BlockingQueue<E> getBlockingQueue()
BlockingQueue, an unbounded queue that additionally supports operations that wait
for the queue to become non-empty when retrieving an element.E - the type of the elements in the queueBlockingQueuepublic <E extends Comparable<E>> Queue<E> getPriorityQueue()
Queue, which instead of the FIFO ordering uses the natural order of the items
added to the queue, so that the retrieved item is always the lowest one. All the items added to this queue must
be non-null and be comparable with the other items in the queue.E - the type of the elements in the queuePriorityQueuepublic <E> List<E> unmodifiable(List<E> input)
E - the type of the elements in the listinput - the list to wrap in an unmodifiable bridgepublic <K,V> Map<K,V> unmodifiable(Map<K,V> input)
K - the type of keys maintained by this mapV - the type of mapped valuesinput - the map to wrap in an unmodifiable bridgepublic <E> Set<E> unmodifiable(Set<E> input)
E - the type of the elements in the setinput - the set to wrap in an unmodifiable bridgepublic <E> Collection<E> unmodifiable(Collection<E> input)
E - the type of the elements in the collectioninput - the collection to wrap in an unmodifiable bridgepublic <E> Collection<E> union(Collection<E> a, Collection<E> b)
Collection containing the union of the given Collections.E - the type of the elements in the collectiona - the first collection, must be non-nullb - the second collection, must be non-nullpublic <E> Collection<E> intersection(Collection<E> a, Collection<E> b)
Collection containing the intersection of the given Collections.E - the type of the elements in the collectiona - the first collection, must be non-nullb - the second collection, must be non-nullpublic <E> Collection<E> disjunction(Collection<E> a, Collection<E> b)
Collection containing the exclusive disjunction (symmetric difference) of the given
Collections.E - the type of the elements in the collectiona - the first collection, must be non-nullb - the second collection, must be non-nullpublic <E> boolean reverse(List<E> input)
E - the type of the elements in the listinput - the list to reversetrue if the list was successfully reversed, false otherwisepublic <E extends Comparable<E>> boolean sort(List<E> input)
E - the type of the elements in the listinput - the list to sorttrue if the list was successfully sorted, false otherwiseCopyright © 2004–2016 XWiki. All rights reserved.