Package org.anchoranalysis.spatial.box
Class BoundedList<T>
Object
BoundedList<T>
- Type Parameters:
T- type of element in the collection
One or more elements, each with an individual bounding-box, and collectively with a bounding-box
that fully contains them all.
- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionaddObjectsNoBoundingBoxChange(Collection<T> elementsToAdd) Adds elements without changing the bounding-boxassignBoundingBox(BoundingBox boxToAssign) Assigns a new containing bounding-box.assignBoundingBoxAndMap(BoundingBox boxToAssign, UnaryOperator<T> mappingFunction) Assigns a new containing bounding-box and maps each individual element.A bounding-box that must contain all elements in the collectionstatic <T> BoundedList<T> createFromList(List<T> list, Function<T, BoundingBox> extractBoundingBox) Creates for a list, minimally fitting a bounding-box around all elementsstatic <T> BoundedList<T> createSingle(T element, Function<T, BoundingBox> extractBoundingBox) Creates for a single element using its current bounding-box.get(int index) Gets a particular element.list()The collection of element with bounding-boxes.intsize()The number of elements.stream()A stream of elements in the list.
-
Method Details
-
createSingle
public static <T> BoundedList<T> createSingle(T element, Function<T, BoundingBox> extractBoundingBox) Creates for a single element using its current bounding-box.- Parameters:
element- the single elementextractBoundingBox- extracts a bounding box from an element. The operation is assumed to involve no computational cost.- Returns:
- the newly-created list.
-
createFromList
public static <T> BoundedList<T> createFromList(List<T> list, Function<T, BoundingBox> extractBoundingBox) Creates for a list, minimally fitting a bounding-box around all elements- Parameters:
list- the listextractBoundingBox- extracts a bounding box from an element. The operation is assumed to involve no computational cost.- Returns:
- the newly-created list.
-
assignBoundingBox
Assigns a new containing bounding-box.The new box must contain the existing box.
- Parameters:
boxToAssign- the new bounding-box to assign- Returns:
- newly-created with the same list but a different bounding-box
-
assignBoundingBoxAndMap
public BoundedList<T> assignBoundingBoxAndMap(BoundingBox boxToAssign, UnaryOperator<T> mappingFunction) Assigns a new containing bounding-box and maps each individual element.The new box must contain the existing box.
- Parameters:
boxToAssign- the new bounding-box to assignmappingFunction- applied to each element of the list to generate new element- Returns:
- newly-created with the same list but a different bounding-box
-
addObjectsNoBoundingBoxChange
Adds elements without changing the bounding-boxThe operation is immutable.
- Parameters:
elementsToAdd- elements to add (unchanged)- Returns:
- a newly created
BoundedListwith existing and added elements and the same bounding-box
-
size
public int size()The number of elements.- Returns:
- the number of elements.
-
get
Gets a particular element.- Parameters:
index- the index to get an element at.- Returns:
- the element at
index.
-
stream
A stream of elements in the list.- Returns:
- the stream.
-
list
The collection of element with bounding-boxes.This collection should not be altered after the constructor (treated immutably).
-
boundingBox
A bounding-box that must contain all elements in the collection
-