Click or drag to resize
WeightedCollectionT Class
A pool of items with dynamic weights defined.
Inheritance Hierarchy
SystemObject
  JLChnToZ.LuckyPlayer.WeightedRandomizerWeightedCollectionT

Namespace: JLChnToZ.LuckyPlayer.WeightedRandomizer
Assembly: LuckyPlayer (in LuckyPlayer.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
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

Type Parameters

T
Generic type

The WeightedCollectionT type exposes the following members.

Constructors
  NameDescription
Public methodWeightedCollectionT
Constructor.
Public methodWeightedCollectionT(IEnumerableT)
Constructor which will initialize the pool with an array of T.
Public methodWeightedCollectionT(IEqualityComparerT)
Constructor with comparer defined.
Public methodWeightedCollectionT(Int32)
Constructor with capacity defined.
Protected methodWeightedCollectionT(IDictionaryT, IItemWeightT)
Initializes a new instance of the WeightedCollectionT class
Public methodWeightedCollectionT(Int32, IEnumerableT)
Constructor which will initialize the pool with an array of T with enough capacity.
Public methodWeightedCollectionT(Int32, IEqualityComparerT)
Constructor with capacity and comparer defined.
Public methodWeightedCollectionT(Int32, IEqualityComparerT, IEnumerableT)
Constructor which will initialize the pool with an array of T with enough capacity and compare by comparer.
Top
Properties
  NameDescription
Public propertyCount
Top
Methods
  NameDescription
Public methodAdd(T)
Adds an item into the pool with default weight.
Public methodAdd(T, IItemWeightT)
Adds an item into the pool with dynamic weight definition.
Public methodAdd(T, Double)
Adds an item into the pool with static weight.
Public methodAddRange
Batch add items into the pool
Public methodClear
Removes everything from the pool.
Public methodClone
Creates a copy of current pool.
Public methodContains
Is the pool contains the specified item?
Public methodCopyTo
Copy the pool of items into an array starting from arrayIndex.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetCurrentWeight
Gets the weight of an item. If dynamic object is defined, the value will be fetched immediately.
Public methodGetEnumerator
Gets an enumerator object for iterates through every items in the pool, even the weight is zero.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetLargeAmountRandomItems
Get large amount of items from the pool. Assumes all weights are static.
Public methodGetRandomItem(Double)
Get an item from the pool with random value passed.
Public methodGetRandomItem(Random)
Get a random item from the pool.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetWeight(T)
Gets the weight controller object of an item.
Public methodGetWeightTItemWeight(T)
Gets the weight controller object of an item with specific controller type requested.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRemove
Removes an item from the pool.
Public methodRemoveRange
Batch remove items from the pool. (if exists)
Public methodSetWeight(T, IItemWeightT)
Binds the item with a dynamic weight controller
Public methodSetWeight(T, Double)
Sets a static weight of an item.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
Remarks
This class behave like a set.
See Also