tModLoader v2024.08
A mod to make and play Terraria mods
PosData< T >.OrderedSparseLookupBuilder Class Reference

Efficient builder for PosData<T>[] lookups covering the whole world. Must add elements in ascending pos order. More...

Public Member Functions

 OrderedSparseLookupBuilder (int capacity=1048576, bool compressEqualValues=true, bool insertDefaultEntries=false)
 Use compressEqualValues to produce a smaller lookup which won't work with PosData.LookupExact When using compressEqualValues without insertDefaultEntries , unspecified positions will default to the value of the previous specified position More...
 
void Add (int pos, T value)
 
void Add (int x, int y, T value)
 
PosData< T >[] Build ()
 

Detailed Description

Efficient builder for PosData<T>[] lookups covering the whole world. Must add elements in ascending pos order.

Constructor & Destructor Documentation

◆ OrderedSparseLookupBuilder()

PosData< T >.OrderedSparseLookupBuilder.OrderedSparseLookupBuilder ( int  capacity = 1048576,
bool  compressEqualValues = true,
bool  insertDefaultEntries = false 
)

Use compressEqualValues to produce a smaller lookup which won't work with PosData.LookupExact When using compressEqualValues without insertDefaultEntries , unspecified positions will default to the value of the previous specified position

Parameters
capacityDefaults to 1M entries to reduce reallocations. Final built collection will be smaller.
compressEqualValuesReduces the size of the map, but gives unspecified positions a value.
insertDefaultEntriesEnsures unspecified positions are assigned a default value when used with compressEqualValues