Module org.jhotdraw8.icollection
Interface ReadOnlyCollection<E>
- Type Parameters:
E- the element type
- All Superinterfaces:
Iterable<E>
- All Known Subinterfaces:
ImmutableCollection<E>,ImmutableList<E>,ImmutableNavigableSet<E>,ImmutableSequencedCollection<E>,ImmutableSequencedSet<E>,ImmutableSet<E>,ImmutableSortedSet<E>,ReadOnlyList<E>,ReadOnlyNavigableSet<E>,ReadOnlySequencedCollection<E>,ReadOnlySequencedSet<E>,ReadOnlySet<E>,ReadOnlySortedSet<E>
- All Known Implementing Classes:
org.jhotdraw8.icollection.impl.champ.AbstractMutableChampSet,AbstractReadOnlyCollection,AbstractReadOnlyList,AbstractReadOnlySet,ChampSet,ChampVectorSet,CollectionFacade,ImmutableSetFacade,MutableChampSet,MutableChampVectorSet,MutableListFacade,MutableRedBlackSet,MutableSetFacade,MutableVectorList,NavigableSetFacade,ReadOnlyCollectionFacade,ReadOnlyListFacade,ReadOnlyNavigableSetFacade,ReadOnlySequencedCollectionFacade,ReadOnlySequencedSetFacade,ReadOnlySetFacade,ReadOnlySortedSetFacade,RedBlackSet,SequencedCollectionFacade,SequencedSetFacade,SetFacade,VectorList
A read-only interface to a collection.
A collection represents a group of objects, known as its elements.
This interface does not guarantee 'read-only', it actually guarantees 'readable'. We use the prefix 'ReadOnly' because this is the naming convention in JavaFX for interfaces that provide read methods but no write methods.
-
Method Summary
Modifier and TypeMethodDescriptiondefault Collection<E> Wraps this collection in the Collection interface - without copying.default intReturns the Spliterator characteristics of this collection.booleanReturnstrueif this collection contains the specified object.default booleancontainsAll(Iterable<?> c) Returns true if this collection contains all elements of that collection.default booleanisEmpty()Returns true if the collection is empty.static <E> StringiterableToString(Iterable<E> c) Returns a string representation of the provided iterable.iterator()Returns an iterator over the elements in this collection.intsize()Returns the size of the collection.stream()Returns a stream.default Object[]toArray()default <T> T[]toArray(T[] a) Converts the collection to an array.Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
size
int size()Returns the size of the collection.- Returns:
- the size
-
isEmpty
default boolean isEmpty()Returns true if the collection is empty.- Returns:
- true if empty
-
toArray
-
toArray
default <T> T[] toArray(T[] a) Converts the collection to an array.- Type Parameters:
T- the element type- Parameters:
a- a template array- Returns:
- an array
-
stream
Returns a stream.- Returns:
- a stream
-
contains
Returnstrueif this collection contains the specified object.- Parameters:
o- an object- Returns:
trueif this collection contains the specified object
-
iterator
Returns an iterator over the elements in this collection. -
containsAll
Returns true if this collection contains all elements of that collection.- Parameters:
c- another collection- Returns:
- true if this collection contains all of c
-
asCollection
Wraps this collection in the Collection interface - without copying.- Returns:
- the wrapped collection
-
iterableToString
Returns a string representation of the provided iterable. The string representation consists of a list of the iterable's elements in the order they are returned, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters", "(comma and space). Elements are converted to strings as byString.valueOf(Object).- Type Parameters:
E- the element type- Parameters:
c- an iterable- Returns:
- a string representation of the iterable
-
characteristics
default int characteristics()Returns the Spliterator characteristics of this collection.The default implementation in this interface returns
Spliterator.SIZED.- Returns:
- the characteristics
-