Compressed Array
- Overview
- API
- Example
In cases where you have large arrays with the same elements repeating contineously, Any of the Compressed Array can be used to reduce memory ussage.
The basic idea is
Uncompressed Array
can be compressed to
Compressed Array
these implementation only differ by how they store compressed data, They all implement ICompressedArray
#
Implementationscaution
Byte Array is now marked obsolete due to performance concerns use node array instead
Byte List#
This implementation stores the data as a plain list of bytes, ideal for serialization but has a byte conversion overheadNode List#
This implementation stores the data as a list of Node (internal structure { Count, Object }), ideal for in-memory representation
#
UsageCompress()
&Decompress()
- These methods can be used to mutate the internal data and it's stateGetCompressedData()
&GetDecompressedData()
- These methods can be used to access the internal data (Casts are done for you). Could lead toIllegalStateException
if you try to acces data in a state which it is not in currently.GetCompressed()
&GetDecompressed()
- These methods can be used to retive a copy of data in the desired stateGetAt()
&SetAt()
- These methods can be used for indexed access to elements
caution
SetAt() may not be implemented for some of the implementations. do take a look at there data access sections before using.
working on a tool to auto-generate api docs.
Compressed array in action, part of a voxel engine