Class PartitionBase
The base class is used for PropertyDrawer declaration and shared methods between the 2 derived class
Namespace: RandomToolbox
Assembly: cs.temp.dll.dll
Syntax
[Serializable]
public abstract class PartitionBase
Properties
_elements
overriden in derived class to give this class access to partition elements
Declaration
protected abstract IReadOnlyList<PartitionBase.ElementBase> _elements { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<PartitionBase.ElementBase> |
IsCorrect
True if the sum of all elements value is equal to 1.0
Declaration
public bool IsCorrect { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
CorrectPartition(PartitionBase.CorrectionRule, Int32, Single, Single)
Declaration
public void CorrectPartition(PartitionBase.CorrectionRule rule = PartitionBase.CorrectionRule.AdjustAll, int lastEditedValueIndex = 0, float minValue = 0F, float maxValue = 1F)
Parameters
Type | Name | Description |
---|---|---|
PartitionBase.CorrectionRule | rule | |
Int32 | lastEditedValueIndex | |
Single | minValue | |
Single | maxValue |
CorrectPartition(Single[], PartitionBase.CorrectionRule, Int32, Single, Single)
Correct a partition if the sum of value is not equal to 1.0
Declaration
public static void CorrectPartition(float[] values, PartitionBase.CorrectionRule rule = PartitionBase.CorrectionRule.AdjustAll, int lastEditedValueIndex = 0, float minValue = 0F, float maxValue = 1F)
Parameters
Type | Name | Description |
---|---|---|
Single[] | values | values of the partition |
PartitionBase.CorrectionRule | rule | the rule to use when editing values PartitionBase.CorrectionRule |
Int32 | lastEditedValueIndex | specify the last edited value if you don't want it to be changed |
Single | minValue | specify a mininum to use when editing partition values (can't be more than 1/n) |
Single | maxValue | specify a maximum to use when editing partition values (can't be less than 1/n) |
DefaultPartitionCorrection(Single[])
Check a partition, and apply Default correction
Declaration
public static void DefaultPartitionCorrection(float[] values)
Parameters
Type | Name | Description |
---|---|---|
Single[] | values | an array of values |
GetIndex(Single)
Return the index of elements at the given value in the partition range
Declaration
public int GetIndex(float value)
Parameters
Type | Name | Description |
---|---|---|
Single | value | value in the 0-1 range |
Returns
Type | Description |
---|---|
Int32 | Return 0 if given value is lower than 0, last index of elements list if value is more than 1, or -1 if list is empty |
SetValue(Int32, Single, PartitionBase.CorrectionRule)
Declaration
public void SetValue(int index, float value, PartitionBase.CorrectionRule rule = PartitionBase.CorrectionRule.AdjustAll)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | |
Single | value | |
PartitionBase.CorrectionRule | rule |
SetValues(Single[], PartitionBase.CorrectionRule)
Set the values for all elements in the partitions. If the number of given value is lower than the current number of elements, the remaining elements value will be set to zero. If the number of given value is higher than the current number of elements, the remaining given value will be ignored. If the sum of values is not equal to 1.0, the partition will be corrected using the given correction rule (or the default one)
Declaration
public virtual void SetValues(float[] values, PartitionBase.CorrectionRule rule = PartitionBase.CorrectionRule.AdjustAll)
Parameters
Type | Name | Description |
---|---|---|
Single[] | values | An array of float value that sum up to 1.0 |
PartitionBase.CorrectionRule | rule | The correction rule to use if the sum is not 1.0 |