Class BoundedList<T>

Object
BoundedList<T>
Type Parameters:
T - type of element in the collection

public class BoundedList<T> extends Object
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 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 element
      extractBoundingBox - 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 list
      extractBoundingBox - extracts a bounding box from an element. The operation is assumed to involve no computational cost.
      Returns:
      the newly-created list.
    • assignBoundingBox

      public BoundedList<T> assignBoundingBox(BoundingBox boxToAssign)
      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 assign
      mappingFunction - applied to each element of the list to generate new element
      Returns:
      newly-created with the same list but a different bounding-box
    • addObjectsNoBoundingBoxChange

      public BoundedList<T> addObjectsNoBoundingBoxChange(Collection<T> elementsToAdd)
      Adds elements without changing the bounding-box

      The operation is immutable.

      Parameters:
      elementsToAdd - elements to add (unchanged)
      Returns:
      a newly created BoundedList with existing and added elements and the same bounding-box
    • size

      public int size()
      The number of elements.
      Returns:
      the number of elements.
    • get

      public T get(int index)
      Gets a particular element.
      Parameters:
      index - the index to get an element at.
      Returns:
      the element at index.
    • stream

      public Stream<T> stream()
      A stream of elements in the list.
      Returns:
      the stream.
    • list

      public List<T> list()
      The collection of element with bounding-boxes.

      This collection should not be altered after the constructor (treated immutably).

    • boundingBox

      public BoundingBox boundingBox()
      A bounding-box that must contain all elements in the collection