Class MarkCollection

Object
MarkCollection
All Implemented Interfaces:
Serializable, Iterable<Mark>

public final class MarkCollection extends Object implements Iterable<Mark>, Serializable
An ordered collection of Marks.

This is often termed a configuration in marked-point-processes academic literature.

Author:
Owen Feehan
See Also:
  • Constructor Details

    • MarkCollection

      public MarkCollection()
      Creates with no elements in the collection.
    • MarkCollection

      public MarkCollection(Stream<Mark> stream)
      Creates from a stream of Marks.
      Parameters:
      stream - the stream of marks to add to the collection.
    • MarkCollection

      public MarkCollection(Mark mark)
      Creates from a single Mark.
      Parameters:
      mark - the mark to add to the collection.
    • MarkCollection

      public MarkCollection(List<Mark> marks)
      Creates a new MarkCollection instance.
      Parameters:
      marks - The underlying List that stores the Marks in the collection.
  • Method Details

    • shallowCopy

      public MarkCollection shallowCopy()
      Creates a shallow copy of the collection.
      Returns:
      a new MarkCollection with the same marks.
    • deepCopy

      public MarkCollection deepCopy()
      Creates a deep copy of the collection.
      Returns:
      a new MarkCollection with duplicates of all marks.
    • add

      public boolean add(Mark mark)
      Adds a mark to the collection.
      Parameters:
      mark - the mark to add.
      Returns:
      true if the mark was added successfully.
    • addAll

      public void addAll(MarkCollection marks)
      Adds all marks from another collection to this collection.
      Parameters:
      marks - the collection of marks to add.
    • contains

      public boolean contains(Object obj)
      Checks if the collection contains a specific object.
      Parameters:
      obj - the object to check for.
      Returns:
      true if the object is in the collection.
    • isEmpty

      public final boolean isEmpty()
      Checks if the collection is empty.
      Returns:
      true if the collection contains no marks.
    • size

      public final int size()
      Returns the number of marks in the collection.
      Returns:
      the size of the collection.
    • iterator

      public final Iterator<Mark> iterator()
      Specified by:
      iterator in interface Iterable<Mark>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • remove

      public Mark remove(int index)
      Removes a mark at a specific index.
      Parameters:
      index - the index of the mark to remove.
      Returns:
      the removed mark.
    • removeTwo

      public void removeTwo(int index1, int index2)
      Removes two marks at specified indices.
      Parameters:
      index1 - the first index.
      index2 - the second index.
    • randomIndex

      public final int randomIndex(RandomNumberGenerator randomNumberGenerator)
      Generates a random index within the collection.
      Parameters:
      randomNumberGenerator - the random number generator to use.
      Returns:
      a random index.
    • get

      public Mark get(int index)
      Gets a mark at a specific index.
      Parameters:
      index - the index of the mark to get.
      Returns:
      the mark at the specified index.
    • randomMark

      public final Mark randomMark(RandomNumberGenerator randomNumberGenerator)
      Gets a random mark from the collection.
      Parameters:
      randomNumberGenerator - the random number generator to use.
      Returns:
      a randomly selected mark.
    • exchange

      public final void exchange(int index, Mark markToAssign)
      Replaces the mark at a specific index.
      Parameters:
      index - the index to replace.
      markToAssign - the new mark to assign.
    • indexOf

      public int indexOf(Mark mark)
      Finds the index of a specific mark in the collection.
      Parameters:
      mark - the mark to find.
      Returns:
      the index of the mark, or -1 if not found.
    • deriveObjects

      public ObjectCollection deriveObjects(Dimensions dimensions, RegionMembershipWithFlags regionMembership)
      Derives objects from the marks in the collection.
      Parameters:
      dimensions - the dimensions to use.
      regionMembership - the region membership to consider.
      Returns:
      a collection of derived objects.
    • scaleXY

      public void scaleXY(ScaleFactor scaleFactor) throws CheckedUnsupportedOperationException
      Scales all marks in the collection in X and Y dimensions.
      Parameters:
      scaleFactor - how much to scale by.
      Throws:
      CheckedUnsupportedOperationException - if scaling is not supported for any mark.
    • marksAt

      public MarkCollection marksAt(Point3i point, RegionMap regionMap, int regionID)
      Finds marks at a specific point that belong to a specific region.
      Parameters:
      point - the point to check.
      regionMap - the region map to use.
      regionID - the ID of the region to consider.
      Returns:
      a new MarkCollection containing the matching marks.
    • equalsDeep

      public boolean equalsDeep(MarkCollection other)
      Checks if this collection is deeply equal to another.
      Parameters:
      other - the other collection to compare with.
      Returns:
      true if the collections are deeply equal.
    • createIdHashMap

      public Map<Integer,Mark> createIdHashMap()
      Creates a map of marks indexed by their IDs.
      Returns:
      a Map where keys are mark IDs and values are the corresponding marks.
    • createIdArr

      public int[] createIdArr()
      Creates an array of mark IDs.
      Returns:
      an array containing the IDs of all marks in the collection.
    • createSet

      public Set<Mark> createSet()
      Creates a set of all marks in the collection.
      Returns:
      a Set containing all marks in the collection.
    • createHashMapToId

      public Map<Mark,Integer> createHashMapToId()
      Creates a map of marks to their indices in the collection.
      Returns:
      a Map where keys are marks and values are their indices.
    • createMerged

      public MarkCollection createMerged(MarkCollection toMerge)
      Creates a new collection by merging this collection with another.
      Parameters:
      toMerge - the collection to merge with.
      Returns:
      a new MarkCollection containing all unique marks from both collections.
    • boxList

      public List<BoundingBox> boxList(Dimensions dimensions, int regionID)
      Creates a list of bounding boxes for all marks in the collection.
      Parameters:
      dimensions - the dimensions to use.
      regionID - the ID of the region to consider.
      Returns:
      a List of BoundingBox objects.
    • set

      public Mark set(int index, Mark element)
      Replaces the mark at a specific index.
      Parameters:
      index - the index to replace.
      element - the new mark to set.
      Returns:
      the mark previously at the specified position.
    • getMarks

      public List<Mark> getMarks()
      The underlying List that stores the Marks in the collection.