Class HashChunkContainer<T>
This is an alternative class to the OctreeChunkContainer, rather than storing chunks in a tree we store them in a hash table.
This will use slightly more memory, but gives a faster speed lookup for single chunks, and similar speed for ranges.
Note: In order to get chunk level locking, rather than lock the whole container during each update, the Count may not always be correct and should only be treaded as a guide.
e.g. Don't use Count to create a new array, create a List instead, that way if count is wrong it wont matter as the list will auto expand itself.
Inheritance
System.Object
HashChunkContainer<T>
Implements
System.IDisposable
Assembly: Eco.Shared.dll
Syntax
public sealed class HashChunkContainer<T> : Object, IChunkContainer<T>, IDisposable where T : class, IChunk
Type Parameters
Constructors
HashChunkContainer(Boolean)
Declaration
public HashChunkContainer(bool threadSafe)
Parameters
Type |
Name |
Description |
System.Boolean |
threadSafe |
|
Properties
Count
Declaration
public int Count { get; }
Property Value
Type |
Description |
System.Int32 |
|
Item[Vector3i]
Declaration
public T this[Vector3i pos] { get; set; }
Parameters
Property Value
Methods
Add(Vector3i, T)
Declaration
public void Add(Vector3i pos, T chunk)
Parameters
Type |
Name |
Description |
Vector3i |
pos |
|
T |
chunk |
|
AsArray()
Declaration
Returns
Clear()
Declaration
CollectColumn(Vector2i, Int32, Queue<T>)
Returns all non-empty chunks in the column. Starts from 0 to maxY
(exclusive).
Declaration
public int CollectColumn(Vector2i column, int maxY, Queue<T> buffer)
Parameters
Type |
Name |
Description |
Vector2i |
column |
|
System.Int32 |
maxY |
|
System.Collections.Generic.Queue<T> |
buffer |
|
Returns
Type |
Description |
System.Int32 |
|
CollectRange(WorldRange, Queue<T>)
Gets chunks at given range to the buffer, this excludes chunks at max.
Declaration
public int CollectRange(WorldRange worldRange, Queue<T> buffer)
Parameters
Type |
Name |
Description |
WorldRange |
worldRange |
The range to get the chunks from.
|
System.Collections.Generic.Queue<T> |
buffer |
The buffer to load the resulting chunks collection to.
|
Returns
Type |
Description |
System.Int32 |
The count of added chunks.
|
Dispose()
Declaration
Remove(T)
Declaration
public void Remove(T chunk)
Parameters
Type |
Name |
Description |
T |
chunk |
|
TryGetValue(Vector3i, out T)
Declaration
public bool TryGetValue(Vector3i pos, out T chunk)
Parameters
Type |
Name |
Description |
Vector3i |
pos |
|
T |
chunk |
|
Returns
Type |
Description |
System.Boolean |
|
Implements
System.IDisposable
Extension Methods