Interface ICollection<E>
-
- Type Parameters:
E
- type of elements stored in the list
- All Superinterfaces:
java.util.Collection<E>
,java.lang.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
public interface ICollection<E> extends java.util.Collection<E>
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:
List
,Deque
,ArrayList
,LinkedList
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
containsIf(java.util.function.Predicate<? super E> predicate)
Determines whether the list contains a matching element.ICollection<E>
copy()
Returns a copy of this collection with all its elements.default int
countIf(java.util.function.Predicate<? super E> predicate)
Counts how many elements in the list match the predicate.ICollection<E>
crop()
Returns an empty copy of this collection.ICollection<E>
filter(java.util.function.Predicate<? super E> predicate)
Create a new collection by applying the specified filter to all elements.<R> IList<R>
filterMap(java.util.function.Predicate<E> filter, java.util.function.Function<E,R> func)
Create a new list by applying the specified filter first and then the mapping function to all elements selected.<R,C extends java.util.Collection<R>>
IList<R>flatMap(java.util.function.Function<E,C> func)
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
getFirstOrNull()
Returns the first element stored in the collection.default E
getIf(java.util.function.Predicate<? super E> predicate)
Returns the first element stored in the collection which matches the predicate.default E
getSingle()
Returns the only element stored in the collection.default E
getSingleOrNull()
Returns the only element stored in the collection or null if the collection is empty.<R> IList<R>
map(java.util.function.Function<E,R> func)
Create a new list by applying the specified mapping function to all elements.<R> IList<R>
mapFilter(java.util.function.Function<E,R> func, java.util.function.Predicate<R> filter)
Create a new list by applying the specified mapping function to all elements and then filtering it.
-
-
-
Method Detail
-
getFirst
default E 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
default E 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
default E 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
default E 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
default E getIf(java.util.function.Predicate<? super E> predicate)
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
default boolean containsIf(java.util.function.Predicate<? super E> predicate)
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
default int countIf(java.util.function.Predicate<? super E> predicate)
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
ICollection<E> filter(java.util.function.Predicate<? super E> predicate)
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
<R> IList<R> map(java.util.function.Function<E,R> func)
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
<R,C extends java.util.Collection<R>> IList<R> flatMap(java.util.function.Function<E,C> func)
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
<R> IList<R> mapFilter(java.util.function.Function<E,R> func, java.util.function.Predicate<R> filter)
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
<R> IList<R> filterMap(java.util.function.Predicate<E> filter, java.util.function.Function<E,R> func)
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
-
-