public interface UnmodCollection<E> extends Collection<E>, UnmodIterable<E>, Sized
Iterable
with a size (a size() method) and unfortunately a contains() method
(deprecated on Lists).
Collection defines the return of Map.values() which can have duplicates and may be ordered, or
unordered. For this reason, I don't think it's possible to define an equals() method on Collection
that works in all circumstances (when comparing it to a List, a Set, or another amorphous
Collection). I don't think Map.values() would exist if Generics had existed and Map had
implemented Iterable<Entry> from the beginning.
UnmodCollection is an unmodifiable version of Collection
which formalizes the return type of Collections.unmodifiableCollection() and Map.values().Modifier and Type | Method and Description |
---|---|
default boolean |
add(E e)
Deprecated.
|
default boolean |
addAll(Collection<? extends E> c)
Deprecated.
|
default void |
clear()
Deprecated.
|
default boolean |
containsAll(Collection<?> c)
The default implementation of this method has O(this.size() + that.size()) or O(n) performance.
|
default boolean |
isEmpty() |
UnmodIterator<E> |
iterator()
An unmodifiable iterator A one-time use, mutable, not-thread-safe way to get each value of the underling collection in
turn.
|
default boolean |
remove(Object o)
Deprecated.
|
default boolean |
removeAll(Collection<?> c)
Deprecated.
|
default boolean |
removeIf(Predicate<? super E> filter)
Deprecated.
|
default boolean |
retainAll(Collection<?> c)
Deprecated.
|
default Object[] |
toArray()
This method goes against Josh Bloch's Item 25: "Prefer Lists to Arrays", but is provided for backwards
compatibility in some performance-critical situations.
|
default <T> T[] |
toArray(T[] as)
This method goes against Josh Bloch's Item 25: "Prefer Lists to Arrays", but is provided for backwards
compatibility in some performance-critical situations.
|
contains, equals, hashCode, parallelStream, size, spliterator, stream
concat, drop, dropWhile, filter, flatMap, fold, foldUntil, hash, head, map, precat, take, takeWhile, toString
toImList, toImMap, toImSet, toImSortedMap, toImSortedSet, toMutableList, toMutableMap, toMutableSet, toMutableSortedMap, toMutableSortedSet
@Deprecated default boolean add(E e)
add
in interface Collection<E>
@Deprecated default boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E>
@Deprecated default void clear()
clear
in interface Collection<E>
default boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E>
default boolean isEmpty()
isEmpty
in interface Collection<E>
UnmodIterator<E> iterator()
iterator
in interface Collection<E>
iterator
in interface Iterable<E>
iterator
in interface UnmodIterable<E>
@Deprecated default boolean remove(Object o)
remove
in interface Collection<E>
@Deprecated default boolean removeAll(Collection<?> c)
removeAll
in interface Collection<E>
@Deprecated default boolean removeIf(Predicate<? super E> filter)
removeIf
in interface Collection<E>
@Deprecated default boolean retainAll(Collection<?> c)
retainAll
in interface Collection<E>
default Object[] toArray()
toArray
in interface Collection<E>
default <T> T[] toArray(T[] as)
MyThing[] things = col.toArray(new MyThing[coll.size()]);
Calling this method any other way causes unnecessary work to be done - an extra memory allocation and potential
garbage collection if the passed array is too small, extra effort to fill the end of the array with nulls if it
is too large.
toArray
in interface Collection<E>
Copyright © 2017. All rights reserved.