M&B: Bannerlord 1.0.0
The horns sound, the ravens gather.
Loading...
Searching...
No Matches
TaleWorlds.Core.MBFastRandomSelector< T > Class Template Reference

Selects distinct entries from a list in random. Does not modify the original list. But keeps a reference to it More...

Classes

struct  IndexEntry
 

Public Member Functions

 MBFastRandomSelector (ushort capacity=MinimumCapacity)
 
 MBFastRandomSelector (IReadOnlyList< T > list, ushort capacity=MinimumCapacity)
 
void Initialize (IReadOnlyList< T > list)
 
void Reset ()
 
void Pack ()
 Reduces the capacity of the selector to list capacity if a selection list is initialized. Or minimum capacity More...
 
bool SelectRandom (out T selection, Predicate< T > conditions=null)
 Picks the next random entry in the selection list satisfying conditions More...
 

Static Public Attributes

const ushort MinimumCapacity = 32
 
const ushort MaximumCapacity = ushort.MaxValue
 

Properties

ushort RemainingCount [get]
 

Detailed Description

REMARK_ATES: Can operate on a list with up to 65,535 elements (max range of 16bit unsigned short) for memory/performance considerations REMARK_ATES: Any changes to the original list will invalidate the random selector.

Constructor & Destructor Documentation

◆ MBFastRandomSelector() [1/2]

◆ MBFastRandomSelector() [2/2]

TaleWorlds.Core.MBFastRandomSelector< T >.MBFastRandomSelector ( IReadOnlyList< T >  list,
ushort  capacity = MinimumCapacity 
)

Member Function Documentation

◆ Initialize()

void TaleWorlds.Core.MBFastRandomSelector< T >.Initialize ( IReadOnlyList< T >  list)

◆ Reset()

◆ Pack()

◆ SelectRandom()

bool TaleWorlds.Core.MBFastRandomSelector< T >.SelectRandom ( out T  selection,
Predicate< T >  conditions = null 
)

Member Data Documentation

◆ MinimumCapacity

const ushort TaleWorlds.Core.MBFastRandomSelector< T >.MinimumCapacity = 32
static

◆ MaximumCapacity

const ushort TaleWorlds.Core.MBFastRandomSelector< T >.MaximumCapacity = ushort.MaxValue
static

Property Documentation

◆ RemainingCount

ushort TaleWorlds.Core.MBFastRandomSelector< T >.RemainingCount
get