TopDown Engine  v4.2
MoreMountains.Tools.MMShufflebag< T > Class Template Reference

A class to use to get more controlled randomness, taking values out of the bag randomly, and never getting them again. More...

Public Member Functions

 MMShufflebag (int initialCapacity)
 Initializes the shufflebag More...
 
virtual void Add (T item, int quantity)
 Adds the specified quantity of the item to the bag More...
 
Pick ()
 Returns a random item from the bag More...
 

Protected Attributes

List< T > _contents
 
_currentItem
 
int _currentIndex = -1
 

Properties

virtual int Capacity [get]
 
virtual int Size [get]
 

Detailed Description

A class to use to get more controlled randomness, taking values out of the bag randomly, and never getting them again.

Usage :

var shuffleBag = new ShuffleBag(40); for (int i = 0; i<40; i++) { newValue = something; shuffleBag.Add(newValue, amount); }

then : float something = shuffleBag.Pick();

Constructor & Destructor Documentation

◆ MMShufflebag()

MoreMountains.Tools.MMShufflebag< T >.MMShufflebag ( int  initialCapacity)

Initializes the shufflebag

Parameters
initialCapacity

Member Function Documentation

◆ Add()

virtual void MoreMountains.Tools.MMShufflebag< T >.Add ( item,
int  quantity 
)
virtual

Adds the specified quantity of the item to the bag

Parameters
item
quantity

◆ Pick()

Returns a random item from the bag

Returns

Member Data Documentation

◆ _contents

List<T> MoreMountains.Tools.MMShufflebag< T >._contents
protected

◆ _currentIndex

int MoreMountains.Tools.MMShufflebag< T >._currentIndex = -1
protected

◆ _currentItem

T MoreMountains.Tools.MMShufflebag< T >._currentItem
protected

Property Documentation

◆ Capacity

virtual int MoreMountains.Tools.MMShufflebag< T >.Capacity
get

◆ Size

virtual int MoreMountains.Tools.MMShufflebag< T >.Size
get

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