Namespace Vintagestory.API.Datastructures
Classes
- ByteDataMap2D
A datastructure to hold 2 dimensional data in the form of ints. Can be used to perfrom bilinear interpolation between individual values Open in GitHub
- CachedCuboidListFaster
Just like CachedCuboidList except we use structs internally, for RAM access performance. We leave CachedCuboidList just as it is for mod backwards compatibility Open in GitHub
- CachingConcurrentDictionary<TKey, TValue>
Exactly like ConcurrentDictionary except that Values is cached for performance, instead of building a new List each time Values is accessed
The cache is only guaranteed up to date if CachedConcurrentDictionary.TryAdd, .TryRemove or [] methods are used to modify the Dictionary otherwise the cache will be updated next time when one of those methods is used
- FastList<TElem>
Does not clear elements in Clear(), but only sets the Count to 0
- FastSmallDictionary<TKey, TValue>
A fast implementation of IDictionary using arrays. Only suitable for small dictionaries, typically 1-20 entries.
Note that Add is implemented differently from a standard Dictionary, it does not check that the key is not already present (and does not throw an ArgumentException)
Additional methods AddIfNotPresent() and Clone() are provided for convenience. There are also additional convenient constructors
- FloatDataMap3D
A datastructure to hold 3 dimensional data in the form of floats Can be used to perfrom trilinear interpolation between individual values Open in GitHub
- IntDataMap2D
A datastructure to hold 2 dimensional data in the form of ints. Can be used to perfrom bilinear interpolation between individual values Open in GitHub
- JsonObject
Elegant, yet somewhat inefficently designed (because wasteful with heap objects) wrapper class to abstract away the type-casting nightmare of JToken O.O Open in GitHub
- LimitedDictionary<TKey, TValue>
Can only hold a limited amount of elements, discards oldest elements once the capacity is reached.
- LimitedList<TElem>
Holds a limited amount of items, discards the lowest index item when an overflow happens
- OrderedDictionary<TKey, TValue>
Same as your normal C# Dictionary but ensures that the order in which the items are added is remembered. That way you can iterate over the dictionary with the insert order intact or set/get elements by index. Taken from http://www.codeproject.com/Articles/18615/OrderedDictionary-T-A-generic-implementation-of-IO Please be aware that this is not a very efficient implementation, recommed use only for small sets of data.
- RotatableCube
A rotatable version of a cuboid. Open in GitHub
- SequencesCache<TElement>
Thread-safe cache of sequences (ordered collections). If two elements return 0 from 'CompareTo' call, they are treated as equal.
- StreamedByteArrayAttribute
When serialized, produces identical byte output to a ByteArrayAttribute. The difference is, for performance, this writes directly to the provided BinaryWriter stream
Intended to be deserialized to a ByteArrayAttribute Open in GitHub
- TreeAttribute
A datastructure to hold generic data for most primitives (int, string, float, etc.). But can also hold generic data using the ByteArrayAttribute + class serialization Open in GitHub
- UniqueQueue<T>
Same as your normal c# queue but ensures that every element is contained only once using a Hashset.
Structs
- CachedSortedSet<TElement>
Collection of unique ordered elements sorted in ascending order.
Thread-safe.
Pros:- no memory overhead
- fast to compare (O(1))
- fast to compare via set operations
- fast to iterate
- fast to check containment
- cheap to copy and pass around
Cons: - slow to construct
- slow to merge via set operations
- no memory overhead
- SmallBoolArray
Suitable for up to 32 bool values, though normally used only for 6. Offers most of the methods available for a bool[], so can be dropped in to existing code
Interfaces
- IAttribute
An attribute from an attribute tree
- IOrderedDictionary<TKey, TValue>
Represents a generic collection of key/value pairs that are ordered independently of the key and value.
- ITreeAttribute
Represents a List of nestable Attributes