public final class ObjectMaskStream extends Object
ObjectCollection
Constructor and Description |
---|
ObjectMaskStream(ObjectCollection delegate) |
Modifier and Type | Method and Description |
---|---|
boolean |
anyMatch(java.util.function.Predicate<ObjectMask> predicate)
Does the predicate evaluate to true on any object in the collection?
|
<E extends Exception> |
filter(CheckedPredicate<ObjectMask,E> predicate,
Class<? extends Exception> throwableClass)
Filters a
ObjectCollection to include certain items based on a predicate |
ObjectCollection |
filter(java.util.function.Predicate<ObjectMask> predicate)
Filters a
ObjectCollection to include certain items based on a predicate |
ObjectCollection |
filterAndMap(java.util.function.Predicate<ObjectMask> predicate,
java.util.function.UnaryOperator<ObjectMask> mapFunction)
|
ObjectCollection |
filterExclude(java.util.function.Predicate<ObjectMask> predicate)
Filters a
ObjectCollection to exclude certain items based on a predicate |
ObjectCollection |
filterSubset(java.util.function.Predicate<ObjectMask> predicate,
Collection<Integer> indices)
Like
filter(java.util.function.Predicate<org.anchoranalysis.image.voxel.object.ObjectMask>) but only operates on certain indices of the collection. |
java.util.stream.Stream<ObjectMask> |
filterSubsetStream(java.util.function.Predicate<ObjectMask> predicate,
Collection<Integer> indices)
Like
filterSubset(java.util.function.Predicate<org.anchoranalysis.image.voxel.object.ObjectMask>, java.util.Collection<java.lang.Integer>) but returns a stream rather than a ObjectCollection . |
<E extends Exception> |
flatMap(Class<? extends Exception> throwableClass,
CheckedFunction<ObjectMask,ObjectCollection,E> mapFunction)
Like a typical
flatMap() operation but accepts a mapping function that throws a
checked exception. |
ObjectCollection |
flatMap(java.util.function.Function<ObjectMask,ObjectCollection> mapFunction)
Creates a new
ObjectCollection after mapping each item to several others. |
<E extends Exception> |
map(CheckedFunction<ObjectMask,ObjectMask,E> mapFunction)
Creates a new
ObjectCollection after mapping each item to another. |
ObjectCollection |
mapBoundingBoxChangeExtent(BoundingBox boxToAssign)
Creates a new
ObjectCollection after mapping the bounding-box on each object (while
maybe changing the extent). |
ObjectCollection |
mapBoundingBoxPreserveExtent(java.util.function.UnaryOperator<BoundingBox> mapFunction)
Creates a new
ObjectCollection after mapping the bounding-box on each object (whose
extent should remain unchanged). |
<T,E extends Exception> |
mapToList(CheckedFunction<ObjectMask,T,E> mapFunction)
Creates a new
List after mapping each item to another type. |
<T,E extends Exception> |
mapToListOptional(CheckedFunction<ObjectMask,Optional<T>,E> mapFunction)
Creates a new
List after mapping each item to another (optional) type |
<T,E extends Exception> |
mapToSortedSet(CheckedFunction<ObjectMask,T,E> mapFunction)
Creates a new
SortedSet after mapping each item to another type. |
OptionalInt |
maxAsInt(java.util.function.ToIntFunction<ObjectMask> function)
Finds the maximum value of a function applied to each object in the collection.
|
OptionalInt |
minAsInt(java.util.function.ToIntFunction<ObjectMask> function)
Finds the minimum value of a function applied to each object in the collection.
|
Set<ObjectMask> |
toSet()
Converts to a
HashSet . |
public ObjectMaskStream(ObjectCollection delegate)
public <E extends Exception> ObjectCollection map(CheckedFunction<ObjectMask,ObjectMask,E> mapFunction) throws E extends Exception
ObjectCollection
after mapping each item to another.
This is an immutable operation.
E
- exception-type that can occur during mappingmapFunction
- performs mappingE
- if an exception is thrown by the mapping function.E extends Exception
public ObjectCollection mapBoundingBoxPreserveExtent(java.util.function.UnaryOperator<BoundingBox> mapFunction)
ObjectCollection
after mapping the bounding-box on each object (whose
extent should remain unchanged).
See ObjectMask.mapBoundingBoxPreserveExtent(UnaryOperator)
for details on the
mapping.
This is an immutable operation.
mapFunction
- maps the bounding-box to a new bounding-boxpublic ObjectCollection mapBoundingBoxChangeExtent(BoundingBox boxToAssign)
ObjectCollection
after mapping the bounding-box on each object (while
maybe changing the extent).
See ObjectMask.mapBoundingBoxChangeExtent(org.anchoranalysis.spatial.box.BoundingBox)
for details on the mapping.
This is an immutable operation.
Precondition: the new bounding-box's extent must be greater than or equal to the existing extent in all dimensions.
boxToAssign
- the bounding box to assign to the newly created objectpublic <T,E extends Exception> List<T> mapToList(CheckedFunction<ObjectMask,T,E> mapFunction) throws E extends Exception
List
after mapping each item to another type.
This is an immutable operation.
T
- destination type for the mappingE
- exception that can be thrown during mappingmapFunction
- performs mappingE
- if an exception occurs during mappingE extends Exception
public <T,E extends Exception> List<T> mapToListOptional(CheckedFunction<ObjectMask,Optional<T>,E> mapFunction) throws E extends Exception
List
after mapping each item to another (optional) type
Items are only included if the output type is not-empty()
This is an immutable operation.
T
- destination type for the mappingE
- exception that can be thrown during mappingmapFunction
- performs mappingE
- if an exception occurs during mappingE extends Exception
public <T,E extends Exception> SortedSet<T> mapToSortedSet(CheckedFunction<ObjectMask,T,E> mapFunction) throws E extends Exception
SortedSet
after mapping each item to another type.
This is an immutable operation.
T
- destination type for the mappingE
- exception that can be thrown during mappingmapFunction
- performs mappingE
- if an exception occurs during mappingE extends Exception
public ObjectCollection flatMap(java.util.function.Function<ObjectMask,ObjectCollection> mapFunction)
ObjectCollection
after mapping each item to several others.
This is an immutable operation.
mapFunction
- performs flat-mappingpublic <E extends Exception> ObjectCollection flatMap(Class<? extends Exception> throwableClass, CheckedFunction<ObjectMask,ObjectCollection,E> mapFunction) throws E extends Exception
flatMap()
operation but accepts a mapping function that throws a
checked exception.
This is an immutable operation.
E
- exception-type that can be thrown by mapFunction
.throwableClass
- the class of E
.mapFunction
- performs flat-mapping.E
- if its thrown by mapFunction
.E extends Exception
public ObjectCollection filter(java.util.function.Predicate<ObjectMask> predicate)
ObjectCollection
to include certain items based on a predicate
This is an immutable operation.
predicate
- iff true object is included, otherwise excluded.public <E extends Exception> ObjectCollection filter(CheckedPredicate<ObjectMask,E> predicate, Class<? extends Exception> throwableClass) throws E extends Exception
ObjectCollection
to include certain items based on a predicate
This is an immutable operation.
E
- an exception that may be thrown by predicate
.predicate
- iff true object is included, otherwise excluded.throwableClass
- the class of E
.E
- if the exception is thrown during filtering.E extends Exception
public ObjectCollection filterExclude(java.util.function.Predicate<ObjectMask> predicate)
ObjectCollection
to exclude certain items based on a predicate
This is an immutable operation.
predicate
- iff true object is excluded, otherwise includedpublic ObjectCollection filterAndMap(java.util.function.Predicate<ObjectMask> predicate, java.util.function.UnaryOperator<ObjectMask> mapFunction)
filter(java.util.function.Predicate<org.anchoranalysis.image.voxel.object.ObjectMask>)
and then a map(org.anchoranalysis.core.functional.checked.CheckedFunction<org.anchoranalysis.image.voxel.object.ObjectMask, org.anchoranalysis.image.voxel.object.ObjectMask, E>)
.
This is an immutable operation.
mapFunction
- performs mappingpredicate
- iff true object is included, otherwise excludedpublic ObjectCollection filterSubset(java.util.function.Predicate<ObjectMask> predicate, Collection<Integer> indices)
filter(java.util.function.Predicate<org.anchoranalysis.image.voxel.object.ObjectMask>)
but only operates on certain indices of the collection.
This is an immutable operation
predicate
- iff true object is included, otherwise excludedindices
- which indices of the collection to considerpublic java.util.stream.Stream<ObjectMask> filterSubsetStream(java.util.function.Predicate<ObjectMask> predicate, Collection<Integer> indices)
filterSubset(java.util.function.Predicate<org.anchoranalysis.image.voxel.object.ObjectMask>, java.util.Collection<java.lang.Integer>)
but returns a stream rather than a ObjectCollection
.
This is an immutable operation
predicate
- iff true object is included, otherwise excludedindices
- which indices of the collection to considerpublic boolean anyMatch(java.util.function.Predicate<ObjectMask> predicate)
predicate
- evaluates to true or false for a particular objectpublic Set<ObjectMask> toSet()
HashSet
.public OptionalInt maxAsInt(java.util.function.ToIntFunction<ObjectMask> function)
function
- function to applypublic OptionalInt minAsInt(java.util.function.ToIntFunction<ObjectMask> function)
function
- function to applyCopyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.