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 boolean
containsIf
(Predicate<? super E> predicate) Determines whether the list contains a matching element.copy()
Returns a copy of this collection with all its elements.default int
Counts 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 E
getFirst()
Returns the first element stored in the collection.default E
Returns the first element stored in the collection.default E
Returns the first element stored in the collection which matches the predicate.default E
Returns the only element stored in the collection.default E
Returns 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, aNoSuchElementException
is 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, aNoSuchElementException
is 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, aNoSuchElementException
is thrown.- Returns:
- only element stored in the collection or null if empty
-
getIf
Returns the first element stored in the collection which matches the predicate. If the collection is empty of no element matches, null is returned.- Returns:
- first element matching the predicate or null if not founds
-
containsIf
Determines whether the list contains a matching element.- Parameters:
predicate
- predicate used to search element- Returns:
- true if the list contains a matching element, false otherwise
-
countIf
Counts how many elements in the list match the predicate.- Parameters:
predicate
- a predicate which returnstrue
for elements to be counted- Returns:
- count how many elements in the list match the predicate
-
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
Create a new list by applying the specified mapping function to all elements. The returned list is of typeIList
, typicallyGapList
unless the original type isBigList
.- Parameters:
func
- mapping function- Returns:
- created list
-
flatMap
Create a new list by applying the specified mapping function to all elements. The returned list is of typeIList
, typicallyGapList
unless the original type isBigList
.- Parameters:
func
- mapping function- Returns:
- created list
-
mapFilter
Create a new list by applying the specified mapping function to all elements and then filtering it. The returned list is of typeIList
, typicallyGapList
unless the original type isBigList
.- Parameters:
func
- mapping functionfilter
- filter predicate- Returns:
- created list
-
filterMap
Create a new list by applying the specified filter first and then the mapping function to all elements selected. The returned list is of typeIList
, typicallyGapList
unless the original type isBigList
.- Parameters:
filter
- filter predicatefunc
- mapping function- Returns:
- created list
-
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
-