Space Engineers
Public Member Functions | Properties | List of all members
VRage.Generics.MyWeightDictionary< T > Class Template Reference

Contains items of any type. Each item has weight (float value). Allows to get item based on weight. More...

Public Member Functions

 MyWeightDictionary (Dictionary< T, float > data)
 Initializes a new instance of the MyWeightDictionary class. More...
 
float GetSum ()
 Gets sum of weights. More...
 
GetItemByWeightNormalized (float weightNormalized)
 Gets item based on weight. More...
 
GetItemByWeight (float weight)
 Gets item based on weight. More...
 
GetRandomItem (Random rnd)
 Gets random item based on weight. More...
 

Properties

int Count [get]
 

Detailed Description

Contains items of any type. Each item has weight (float value). Allows to get item based on weight.

Template Parameters
TThe item type

Definition at line 13 of file MyWeightDictionary.cs.

Constructor & Destructor Documentation

VRage.Generics.MyWeightDictionary< T >.MyWeightDictionary ( Dictionary< T, float >  data)
inline

Initializes a new instance of the MyWeightDictionary class.

Parameters
dataDictionary with items and weights.

Definition at line 22 of file MyWeightDictionary.cs.

Member Function Documentation

T VRage.Generics.MyWeightDictionary< T >.GetItemByWeight ( float  weight)
inline

Gets item based on weight.

Parameters
weightWeight, value from 0 to sum.
Returns

Definition at line 64 of file MyWeightDictionary.cs.

T VRage.Generics.MyWeightDictionary< T >.GetItemByWeightNormalized ( float  weightNormalized)
inline

Gets item based on weight.

Parameters
weightNormalizedWeight, value from 0 to 1.
Returns
The item.

Definition at line 54 of file MyWeightDictionary.cs.

T VRage.Generics.MyWeightDictionary< T >.GetRandomItem ( Random  rnd)
inline

Gets random item based on weight.

Returns
The item.

Definition at line 82 of file MyWeightDictionary.cs.

float VRage.Generics.MyWeightDictionary< T >.GetSum ( )
inline

Gets sum of weights.

Returns
The sum of all weights.

Definition at line 44 of file MyWeightDictionary.cs.

Property Documentation

Definition at line 33 of file MyWeightDictionary.cs.


The documentation for this class was generated from the following file: