Class RandomCollectionWithAddCriteria<T>
- Type Parameters:
T
- type of the pair
- All Implemented Interfaces:
UpdatableMarks
- Direct Known Subclasses:
MarkPairCollection
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 Summary
ConstructorsConstructorDescriptionRandomCollectionWithAddCriteria
(Class<?> pairTypeClass) Creates a new instance with the specified pair type class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(MemoForIndex marksExisting, VoxelizedMarkMemo newMark) Adds a new mark to the existing set of marks.boolean
containsMark
(Mark mark) Checks if the collection contains a specific mark.Creates a set of unique pairs from the graph.deepCopy()
Creates a deep copy of this RandomCollectionWithAddCriteria.void
exchange
(MemoForIndex memo, VoxelizedMarkMemo oldMark, int indexOldMark, VoxelizedMarkMemo newMark) Exchanges an existing mark with a new one.The criteria used to determine which marks to add.getMarks()
Gets all marks in the collection.getPairsFor
(Mark mark) Gets all pairs associated with a specific mark.Class
<?> The class type of the pair.void
initUpdatableMarks
(MemoForIndex marks, EnergyStack stack, Logger logger, SharedFeatures sharedFeatures) Initializes the updatable marks with necessary context.boolean
isMarksSpan
(MarkCollection marks) Checks if the givenMarkCollection
spans all marks in this collection.void
remove
(MemoForIndex marksExisting, VoxelizedMarkMemo mark) Removes a mark from the existing set of marks.sampleRandomPairNonUniform
(RandomNumberGenerator randomNumberGenerator) Samples a random pair of items from the collection using a non-uniform distribution.void
setAddCriteria
(AddCriteria<T> addCriteria) The criteria used to determine which marks to add.void
setPairTypeClass
(Class<?> pairTypeClass) The class type of the pair.Creates a shallow copy of this RandomCollectionWithAddCriteria.Methods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
RandomCollectionWithAddCriteria
Creates a new instance with the specified pair type class.- Parameters:
pairTypeClass
- the class type of the pair
-
-
Method Details
-
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
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
-
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 marksnewMark
- 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 indexingoldMark
- the mark to be replacedindexOldMark
- the index of the old marknewMark
- 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 marksmark
- the mark to be removed- Throws:
UpdateMarkSetException
- if the removal operation fails
-
createPairsUnique
Creates a set of unique pairs from the graph.- Returns:
- a
Set
of unique pairs
-
getPairsFor
Gets all pairs associated with a specific mark.- Parameters:
mark
- theMark
to get pairs for- Returns:
- a
Collection
of edges (pairs) associated with the mark
-
containsMark
Checks if the collection contains a specific mark.- Parameters:
mark
- theMark
to check for- Returns:
- true if the mark is present in the collection, false otherwise
-
getMarks
Gets all marks in the collection.- Returns:
- a
Collection
of allMark
s in the graph
-
isMarksSpan
Checks if the givenMarkCollection
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
- theMarkCollection
to check against- Returns:
- true if the given collection spans all marks in this collection, false otherwise
-
sampleRandomPairNonUniform
Description copied from class:RandomCollection
Samples a random pair of items from the collection using a non-uniform distribution.- Specified by:
sampleRandomPairNonUniform
in classRandomCollection<T>
- Parameters:
randomNumberGenerator
- The random number generator to use for sampling- Returns:
- A randomly sampled pair of items
-
getPairTypeClass
The class type of the pair. -
setPairTypeClass
The class type of the pair. -
getAddCriteria
The criteria used to determine which marks to add. -
setAddCriteria
The criteria used to determine which marks to add.
-