Class RandomCollectionWithAddCriteria<T>

Object
AnchorBean<RandomCollection<T>>
RandomCollection<T>
RandomCollectionWithAddCriteria<T>
Type Parameters:
T - type of the pair
All Implemented Interfaces:
UpdatableMarks
Direct Known Subclasses:
MarkPairCollection

public class RandomCollectionWithAddCriteria<T> extends RandomCollection<T>
An implementation of a RandomCollection that uses AddCriteria to determine which marks to add.

This class is not a valid bean on its own, as it lacks a default public constructor. To use it in BeanXML, it must be subclassed with such a constructor. However, it is a valid (non-bean) class on its own.

The class is kept non-abstract to allow instantiation when copy methods (shallowCopy, deepCopy, etc.) are called.

  • Constructor Details

    • RandomCollectionWithAddCriteria

      public RandomCollectionWithAddCriteria(Class<?> pairTypeClass)
      Creates a new instance with the specified pair type class.
      Parameters:
      pairTypeClass - the class type of the pair
  • Method Details

    • shallowCopy

      public RandomCollectionWithAddCriteria<T> shallowCopy()
      Creates a shallow copy of this RandomCollectionWithAddCriteria.

      This method creates a new instance with the same pairTypeClass and addCriteria, and copies references to the graph, energyStack, logger, and sharedFeatures.

      Returns:
      a new RandomCollectionWithAddCriteria instance with shallow-copied properties
    • deepCopy

      public RandomCollectionWithAddCriteria<T> deepCopy()
      Creates a deep copy of this RandomCollectionWithAddCriteria.

      This method creates a new instance with the same pairTypeClass and addCriteria, and copies references to the graph, energyStack, logger, and sharedFeatures.

      Returns:
      a new RandomCollectionWithAddCriteria instance with deep-copied properties
    • initUpdatableMarks

      public void initUpdatableMarks(MemoForIndex marks, EnergyStack stack, Logger logger, SharedFeatures sharedFeatures) throws InitializeException
      Description copied from interface: UpdatableMarks
      Initializes the updatable marks with necessary context.
      Parameters:
      marks - the memo for indexing
      stack - the energy stack
      logger - the logger for any logging operations
      sharedFeatures - shared features to be used
      Throws:
      InitializeException - if initialization fails
    • add

      public void add(MemoForIndex marksExisting, VoxelizedMarkMemo newMark) throws UpdateMarkSetException
      Description copied from interface: UpdatableMarks
      Adds a new mark to the existing set of marks.
      Parameters:
      marksExisting - the existing set of marks
      newMark - the new mark to be added
      Throws:
      UpdateMarkSetException - if the addition operation fails
    • exchange

      public void exchange(MemoForIndex memo, VoxelizedMarkMemo oldMark, int indexOldMark, VoxelizedMarkMemo newMark) throws UpdateMarkSetException
      Description copied from interface: UpdatableMarks
      Exchanges an existing mark with a new one.
      Parameters:
      memo - the memo for indexing
      oldMark - the mark to be replaced
      indexOldMark - the index of the old mark
      newMark - the new mark to replace the old one
      Throws:
      UpdateMarkSetException - if the exchange operation fails
    • remove

      public void remove(MemoForIndex marksExisting, VoxelizedMarkMemo mark) throws UpdateMarkSetException
      Description copied from interface: UpdatableMarks
      Removes a mark from the existing set of marks.
      Parameters:
      marksExisting - the existing set of marks
      mark - the mark to be removed
      Throws:
      UpdateMarkSetException - if the removal operation fails
    • createPairsUnique

      public Set<T> createPairsUnique()
      Creates a set of unique pairs from the graph.
      Returns:
      a Set of unique pairs
    • getPairsFor

      public Collection<TypedEdge<Mark,T>> getPairsFor(Mark mark)
      Gets all pairs associated with a specific mark.
      Parameters:
      mark - the Mark to get pairs for
      Returns:
      a Collection of edges (pairs) associated with the mark
    • containsMark

      public boolean containsMark(Mark mark)
      Checks if the collection contains a specific mark.
      Parameters:
      mark - the Mark to check for
      Returns:
      true if the mark is present in the collection, false otherwise
    • getMarks

      public Collection<Mark> getMarks()
      Gets all marks in the collection.
      Returns:
      a Collection of all Marks in the graph
    • isMarksSpan

      public boolean isMarksSpan(MarkCollection marks)
      Checks if the given MarkCollection spans all marks in this collection.

      This method verifies that all marks in the given collection are present in this collection, and that this collection doesn't contain any additional marks.

      Parameters:
      marks - the MarkCollection to check against
      Returns:
      true if the given collection spans all marks in this collection, false otherwise
    • sampleRandomPairNonUniform

      public T sampleRandomPairNonUniform(RandomNumberGenerator randomNumberGenerator)
      Description copied from class: RandomCollection
      Samples a random pair of items from the collection using a non-uniform distribution.
      Specified by:
      sampleRandomPairNonUniform in class RandomCollection<T>
      Parameters:
      randomNumberGenerator - The random number generator to use for sampling
      Returns:
      A randomly sampled pair of items
    • getPairTypeClass

      public Class<?> getPairTypeClass()
      The class type of the pair.
    • setPairTypeClass

      public void setPairTypeClass(Class<?> pairTypeClass)
      The class type of the pair.
    • getAddCriteria

      public AddCriteria<T> getAddCriteria()
      The criteria used to determine which marks to add.
    • setAddCriteria

      public void setAddCriteria(AddCriteria<T> addCriteria)
      The criteria used to determine which marks to add.