Class SimpleWeightedGeneList
java.lang.Object
com.hexagram2021.chromosomelib.registry.SimpleWeightedGeneList
- All Implemented Interfaces:
IWeightedGeneList
- Direct Known Subclasses:
StableWeightedGeneList
Simple implementation of weighted gene list.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.hexagram2021.chromosomelib.registry.IWeightedGeneList
IWeightedGeneList.Context, IWeightedGeneList.Entry, IWeightedGeneList.WeightedGeneListFactory -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.google.common.collect.ImmutableList<IWeightedGeneList.Entry>protected final intprotected final it.unimi.dsi.fastutil.ints.IntListFields inherited from interface com.hexagram2021.chromosomelib.registry.IWeightedGeneList
EMPTY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSimpleWeightedGeneList(com.google.common.collect.ImmutableList<IWeightedGeneList.Entry> entries) -
Method Summary
Modifier and TypeMethodDescriptionallGenes()Get all possible genes in this list.builder()Create a builder for SimpleWeightedGeneList.net.minecraft.core.Holder<Gene>getRandomGene(IWeightedGeneList.Context context) Get a random gene from this list.inttotalWeight(IWeightedGeneList.Context context) Get the total weight of this list.
-
Field Details
-
entries
-
weightPrefixSums
protected final it.unimi.dsi.fastutil.ints.IntList weightPrefixSums -
totalWeight
protected final int totalWeight
-
-
Constructor Details
-
SimpleWeightedGeneList
protected SimpleWeightedGeneList(com.google.common.collect.ImmutableList<IWeightedGeneList.Entry> entries)
-
-
Method Details
-
getRandomGene
Description copied from interface:IWeightedGeneListGet a random gene from this list.- Specified by:
getRandomGenein interfaceIWeightedGeneList- Parameters:
context- the context- Returns:
- a random gene
-
totalWeight
Description copied from interface:IWeightedGeneListGet the total weight of this list.- Specified by:
totalWeightin interfaceIWeightedGeneList- Parameters:
context- the context- Returns:
- the total weight
-
allGenes
Description copied from interface:IWeightedGeneListGet all possible genes in this list.- Specified by:
allGenesin interfaceIWeightedGeneList- Returns:
- all possible genes
-
builder
Create a builder for SimpleWeightedGeneList.- Returns:
- a builder
-