Show / Hide Table of Contents

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
IChunkContainer<T>
System.IDisposable
Namespace: Eco.Shared.Voxel
Assembly: Eco.Shared.dll
Syntax
public sealed class HashChunkContainer<T> : Object, IChunkContainer<T>, IDisposable where T : class, IChunk
Type Parameters
Name Description
T

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
Type Name Description
Vector3i pos
Property Value
Type Description
T

Methods

Add(Vector3i, T)

Declaration
public void Add(Vector3i pos, T chunk)
Parameters
Type Name Description
Vector3i pos
T chunk

AsArray()

Declaration
public T[] AsArray()
Returns
Type Description
T[]

Clear()

Declaration
public void Clear()

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
public void Dispose()

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

IChunkContainer<T>
System.IDisposable

Extension Methods

CommandLine.FeedFromCommandLine(Object)
CommandLine.ToCommandLineArgs(Object, Func<Object, Boolean>)
ListUtil.DepthFirstTraversal<T>(T, Func<T, IEnumerable<T>>)
EnumerableExtensions.SingleItemAsEnumerable<T>(T)
EventUtils.RaiseEvent<TEventArgs>(Object, String, TEventArgs)
PredicateUtils.MatchesAll<TEnumerable, T>(T, TEnumerable)
PredicateUtils.MatchesAll<T>(T, Func<T, Boolean>[])
PredicateUtils.MatchesAny<TEnumerable, T>(T, TEnumerable)
ReflectionUtils.PropertyValue<T>(Object, PropertyInfo)
ReflectionUtils.TryGetPropertyValueByName<T>(Object, String, out T)
ReflectionUtils.GetPropertyValueByName<T>(Object, String)
ReflectionUtils.SetPropertyByName(Object, String, Object)
ReflectionUtils.GetStructPropertyByName<T>(Object, String)
ReflectionUtils.GetStringPropertyByName(Object, String)
ReflectionUtils.ZipByProperty<T>(Object, Object, Object, Func<T, T, T>)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾