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 TypeMethodDescriptionvoidadd(MemoForIndex marksExisting, VoxelizedMarkMemo newMark) Adds a new mark to the existing set of marks.booleancontainsMark(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.voidexchange(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.voidinitUpdatableMarks(MemoForIndex marks, EnergyStack stack, Logger logger, SharedFeatures sharedFeatures) Initializes the updatable marks with necessary context.booleanisMarksSpan(MarkCollection marks) Checks if the givenMarkCollectionspans all marks in this collection.voidremove(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.voidsetAddCriteria(AddCriteria<T> addCriteria) The criteria used to determine which marks to add.voidsetPairTypeClass(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:UpdatableMarksAdds 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:UpdatableMarksExchanges 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:UpdatableMarksRemoves 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
Setof unique pairs
-
getPairsFor
Gets all pairs associated with a specific mark.- Parameters:
mark- theMarkto get pairs for- Returns:
- a
Collectionof edges (pairs) associated with the mark
-
containsMark
Checks if the collection contains a specific mark.- Parameters:
mark- theMarkto check for- Returns:
- true if the mark is present in the collection, false otherwise
-
getMarks
Gets all marks in the collection.- Returns:
- a
Collectionof allMarks in the graph
-
isMarksSpan
Checks if the givenMarkCollectionspans 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- theMarkCollectionto check against- Returns:
- true if the given collection spans all marks in this collection, false otherwise
-
sampleRandomPairNonUniform
Description copied from class:RandomCollectionSamples a random pair of items from the collection using a non-uniform distribution.- Specified by:
sampleRandomPairNonUniformin 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.
-