Reusable Java library of general tools with minimal external dependencies.
For questions or support, please contact us:
Email: support@aoindustries.com
Phone: 1-800-519-9541
Phone: +1-251-607-9556
Web: https://www.aoindustries.com/contact
public class AoCollections extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
AoCollections.PeekIterator<E>
Allows peeking the first element of iteration.
|
| Modifier and Type | Field and Description |
|---|---|
static SortedSet<?> |
EMPTY_SORTED_SET |
| Modifier and Type | Method and Description |
|---|---|
static <E> Iterator<E> |
emptyIterator()
Gets the empty iterator.
|
static <T> SortedSet<T> |
emptySortedSet()
Java 1.8: use standard version
|
static boolean |
equals(Collection<?> collection1,
Collection<?> collection2)
Two collections are considered equal when they are the same size and have the same
elements in the same iteration order.
|
static <E,R extends E> |
filter(List<E> list,
Class<R> clazz)
Filters a list for all elements of a given class.
|
static int |
hashCode(Iterable<?> iterable)
Computes the hashCode of a collection in a manner consistent with
AbstractList.
|
static <T> Collection<T> |
optimalUnmodifiableCollection(Collection<T> collection)
Gets the optimal implementation for unmodifiable collection.
|
static <T> List<T> |
optimalUnmodifiableList(List<T> list)
Gets the optimal implementation for unmodifiable list.
|
static <K,V> Map<K,V> |
optimalUnmodifiableMap(Map<K,V> map)
Gets the optimal implementation for unmodifiable map.
|
static <T> Set<T> |
optimalUnmodifiableSet(Set<T> set)
Gets the optimal implementation for unmodifiable set.
|
static <K,V> SortedMap<K,V> |
optimalUnmodifiableSortedMap(SortedMap<K,V> sortedMap)
Gets the optimal implementation for unmodifiable sorted map.
|
static <T> SortedSet<T> |
optimalUnmodifiableSortedSet(SortedSet<T> sortedSet)
Gets the optimal implementation for unmodifiable sorted set.
|
static <E> AoCollections.PeekIterator<E> |
peekIterator(Iterator<? extends E> iter)
Wraps the provided iterator, allowing peek of first element.
|
static <E> Iterator<E> |
singletonIterator(E value)
Gets an unmodifiable iterator for a single object.
|
static <T> SortedSet<T> |
singletonSortedSet(T o) |
static <T> Collection<T> |
unmodifiableCopyCollection(Collection<T> collection)
Performs defensive shallow copy and returns unmodifiable collection.
|
static <T> List<T> |
unmodifiableCopyList(Collection<T> collection)
Performs defensive shallow copy and returns unmodifiable list.
|
static <K,V> Map<K,V> |
unmodifiableCopyMap(Map<K,V> map)
Performs defensive shallow copy and returns unmodifiable map.
|
static <T> Set<T> |
unmodifiableCopySet(Collection<T> collection)
Performs defensive shallow copy and returns unmodifiable set.
|
static <K,V> SortedMap<K,V> |
unmodifiableCopySortedMap(Map<K,V> map)
Performs defensive shallow copy and returns unmodifiable sorted map.
|
static <T> SortedSet<T> |
unmodifiableCopySortedSet(Collection<T> collection)
Performs defensive shallow copy and returns unmodifiable sorted set.
|
static <E> Iterator<E> |
unmodifiableIterator(Iterator<E> iter)
Wraps an iterator to make it unmodifiable.
|
public static final SortedSet<?> EMPTY_SORTED_SET
public static final <T> SortedSet<T> emptySortedSet()
public static <T> SortedSet<T> singletonSortedSet(T o)
public static <T> Collection<T> optimalUnmodifiableCollection(Collection<T> collection)
Collections.emptyList.
If collection has one element, uses Collections.singletonList.
Otherwise, wraps the collection with Collections.unmodifiableCollection.public static <T> Collection<T> unmodifiableCopyCollection(Collection<T> collection)
public static <T> List<T> optimalUnmodifiableList(List<T> list)
Collections.emptyList.
If list has one element, uses Collections.singletonList.
Otherwise, wraps the list with Collections.unmodifiableList,
and will also call "trimToSize" if the list is an ArrayList.public static <T> List<T> unmodifiableCopyList(Collection<T> collection)
public static <T> Set<T> optimalUnmodifiableSet(Set<T> set)
Collections.emptySet.
If set has one element, uses Collections.singleton.
Otherwise, wraps the set with Collections.unmodifiableSet.public static <T> Set<T> unmodifiableCopySet(Collection<T> collection)
public static <T> SortedSet<T> optimalUnmodifiableSortedSet(SortedSet<T> sortedSet)
emptySortedSet.
If sorted set has one element, uses singletonSortedSet.
Otherwise, wraps the sorted set with Collections.unmodifiableSortedSet.public static <T> SortedSet<T> unmodifiableCopySortedSet(Collection<T> collection)
public static <K,V> Map<K,V> optimalUnmodifiableMap(Map<K,V> map)
Collections.emptyMap.
If map has one element, uses Collections.singletonMap.
Otherwise, wraps the map with Collections.unmodifiableMap.public static <K,V> Map<K,V> unmodifiableCopyMap(Map<K,V> map)
public static <K,V> SortedMap<K,V> optimalUnmodifiableSortedMap(SortedMap<K,V> sortedMap)
emptySortedMap.
If sorted map has one element, uses singletonSortedMap.
Otherwise, wraps the sorted map with Collections.unmodifiableSortedMap.public static <K,V> SortedMap<K,V> unmodifiableCopySortedMap(Map<K,V> map)
public static <E> Iterator<E> emptyIterator()
public static <E> Iterator<E> singletonIterator(E value)
public static <E> Iterator<E> unmodifiableIterator(Iterator<E> iter)
public static <E> AoCollections.PeekIterator<E> peekIterator(Iterator<? extends E> iter)
public static boolean equals(Collection<?> collection1, Collection<?> collection2)
public static int hashCode(Iterable<?> iterable)
AbstractList.hashCode()Copyright © 2000–2016 AO Industries, Inc.. All rights reserved.