Interface ICollection<E>
- Type Parameters:
E- type of elements stored in the list
- All Superinterfaces:
Collection<E>, Iterable<E>
- All Known Implementing Classes:
BigList, BigList.Block, BigList.ReadOnlyBigList, BooleanObjBigList, BooleanObjBigList.ImmutableBooleanObjBigList, BooleanObjGapList, BooleanObjGapList.ImmutableBooleanObjGapList, ByteObjBigList, ByteObjBigList.ImmutableByteObjBigList, ByteObjGapList, ByteObjGapList.ImmutableByteObjGapList, CharObjBigList, CharObjBigList.ImmutableCharObjBigList, CharObjGapList, CharObjGapList.ImmutableCharObjGapList, DoubleObjBigList, DoubleObjBigList.ImmutableDoubleObjBigList, DoubleObjGapList, DoubleObjGapList.ImmutableDoubleObjGapList, FloatObjBigList, FloatObjBigList.ImmutableFloatObjBigList, FloatObjGapList, FloatObjGapList.ImmutableFloatObjGapList, GapList, GapList.ReadOnlyList, IList, IntObjBigList, IntObjBigList.ImmutableIntObjBigList, IntObjGapList, IntObjGapList.ImmutableIntObjGapList, Key1Collection, Key1List, Key1List.ReadOnlyKey1List, Key1Set, Key2Collection, Key2List, Key2List.ReadOnlyKey2List, Key2Set, KeyCollection, KeyCollectionImpl, KeyCollectionImpl.KeyMapList, KeyList, KeyList.ImmutableKeyList, KeyListImpl, KeySet, LongObjBigList, LongObjBigList.ImmutableLongObjBigList, LongObjGapList, LongObjGapList.ImmutableLongObjGapList, ShortObjBigList, ShortObjBigList.ImmutableShortObjBigList, ShortObjGapList, ShortObjGapList.ImmutableShortObjGapList
IList is an abstract class which offers all interfaces offered by both ArrayList and LinkedList.
It also offers additional methods which are then available in all implementations of GapList and BigList.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleancontainsIf(Predicate<? super E> predicate) Determines whether the list contains a matching element.copy()Returns a copy of this collection with all its elements.default intCounts how many elements in the list match the predicate.crop()Returns an empty copy of this collection.Create a new collection by applying the specified filter to all elements.<R> IList<R> Create a new list by applying the specified filter first and then the mapping function to all elements selected.<R, C extends Collection<R>>
IList<R> Create a new list by applying the specified mapping function to all elements.default EgetFirst()Returns the first element stored in the collection.default EReturns the first element stored in the collection.default EReturns the first element stored in the collection which matches the predicate.default EReturns the only element stored in the collection.default EReturns the only element stored in the collection or null if the collection is empty.<R> IList<R> Create a new list by applying the specified mapping function to all elements.<R> IList<R> Create a new list by applying the specified mapping function to all elements and then filtering it.
-
Method Details
-
getFirst
Returns the first element stored in the collection. If the collection is empty, aNoSuchElementExceptionis thrown.- Returns:
- first element stored in the collection
-
getFirstOrNull
Returns the first element stored in the collection. If the collection is empty, null is returned.- Returns:
- first element stored in the collection or null if empty
-
getSingle
Returns the only element stored in the collection. If the collection size is not 1, aNoSuchElementExceptionis thrown.- Returns:
- only element stored in the collection
-
getSingleOrNull
Returns the only element stored in the collection or null if the collection is empty. If the collection's size is greater than 1, aNoSuchElementExceptionis thrown.- Returns:
- only element stored in the collection or null if empty
-
getIf
-
containsIf
-
countIf
-
filter
Create a new collection by applying the specified filter to all elements. The returned collection has the same type as the original one.- Parameters:
predicate- filter predicate- Returns:
- created list
-
map
-
flatMap
-
mapFilter
-
filterMap
-
copy
ICollection<E> copy()Returns a copy of this collection with all its elements.- Returns:
- a copy of this collection
-
crop
ICollection<E> crop()Returns an empty copy of this collection.- Returns:
- an empty copy of this collection
-