WeightedCollectionT Class |
Namespace: JLChnToZ.LuckyPlayer.WeightedRandomizer
public class WeightedCollection<T> : ICollection<T>, IEnumerable<T>, IEnumerable, IDictionary<T, IItemWeight<T>>, ICollection<KeyValuePair<T, IItemWeight<T>>>, IEnumerable<KeyValuePair<T, IItemWeight<T>>>, IDictionary<T, double>, ICollection<KeyValuePair<T, double>>, IEnumerable<KeyValuePair<T, double>>, ICloneable
The WeightedCollectionT type exposes the following members.
Name | Description | |
---|---|---|
WeightedCollectionT |
Constructor.
| |
WeightedCollectionT(IEnumerableT) |
Constructor which will initialize the pool with an array of T.
| |
WeightedCollectionT(IEqualityComparerT) |
Constructor with comparer defined.
| |
WeightedCollectionT(Int32) |
Constructor with capacity defined.
| |
WeightedCollectionT(IDictionaryT, IItemWeightT) | Initializes a new instance of the WeightedCollectionT class | |
WeightedCollectionT(Int32, IEnumerableT) |
Constructor which will initialize the pool with an array of T with enough capacity.
| |
WeightedCollectionT(Int32, IEqualityComparerT) |
Constructor with capacity and comparer defined.
| |
WeightedCollectionT(Int32, IEqualityComparerT, IEnumerableT) |
Constructor which will initialize the pool with an array of T with enough capacity and compare by comparer.
|
Name | Description | |
---|---|---|
Add(T) |
Adds an item into the pool with default weight.
| |
Add(T, IItemWeightT) |
Adds an item into the pool with dynamic weight definition.
| |
Add(T, Double) |
Adds an item into the pool with static weight.
| |
AddRange |
Batch add items into the pool
| |
Clear |
Removes everything from the pool.
| |
Clone |
Creates a copy of current pool.
| |
Contains |
Is the pool contains the specified item?
| |
CopyTo |
Copy the pool of items into an array starting from arrayIndex.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetCurrentWeight |
Gets the weight of an item. If dynamic object is defined, the value will be fetched immediately.
| |
GetEnumerator |
Gets an enumerator object for iterates through every items in the pool, even the weight is zero.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetLargeAmountRandomItems |
Get large amount of items from the pool. Assumes all weights are static.
| |
GetRandomItem(Double) |
Get an item from the pool with random value passed.
| |
GetRandomItem(Random) |
Get a random item from the pool.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GetWeight(T) |
Gets the weight controller object of an item.
| |
GetWeightTItemWeight(T) |
Gets the weight controller object of an item with specific controller type requested.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Remove |
Removes an item from the pool.
| |
RemoveRange |
Batch remove items from the pool. (if exists)
| |
SetWeight(T, IItemWeightT) |
Binds the item with a dynamic weight controller
| |
SetWeight(T, Double) |
Sets a static weight of an item.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
AddT(T, Double, Double) | Overloaded.
Adds an item with a new LuckyControllerT binds with it.
(Defined by Helpers.) | |
AddT(T, Double, Int32, Double) | Overloaded.
Adds an item with a new LimitedLuckyControllerT with it.
(Defined by Helpers.) | |
ResetFineTuneWeightT |
Resets all fine tune weight to 1.
(Defined by Helpers.) | |
ScaleFineTuneWeightT |
Scales all fine tune weight based on 1.
(Defined by Helpers.) |