- Joined
- Dec 12, 2008
- Messages
- 7,385
Gentlemen, I present, the SequentialIntegralDataUnitStorageStructure!
This structure will actually allow you to store data in memory pseudo-sequentially! The memory addresses are not contiguous at the level of the RAM, but this resource emulates it!
It's innovative, and it just works.
Feel free to comment.
This structure will actually allow you to store data in memory pseudo-sequentially! The memory addresses are not contiguous at the level of the RAM, but this resource emulates it!
It's innovative, and it just works.
JASS:
/*****************************
*
* SequentialIntegralDataUnitStorageStructure
* v1.0.0.0
* By Magtheridon96
*
* - Allows the storage of integral data in memory
* sequentially all with O(1) complexity!
*
* API:
* ----
*
* struct SequentialIntegralDataUnitStorageStructure extends array
*
* static method create takes nothing returns thistype
* - This function initializes an instance of the struct
*
* method cache takes integer index, integer memory returns nothing
* - This function caches memory in the given index
*
* method lookup takes integer index returns integer
* - This function lookups the memory stored at a given index
*
* method destroy takes nothing returns nothing
* - This will free all memory used by the array
*
*****************************/
library SequentialIntegralDataUnitStorageStructure
globals
private hashtable h = InitHashtable()
endglobals
struct SequentialIntegralDataUnitStorageStructure extends array
private static thistype array rn
private static integer ic = 0
static method create takes nothing returns thistype
local thistype this = rn[0]
if this == 0 then
set ic = ic + 1
set this = ic
else
set rn[0] = rn[this]
endif
call FlushChildHashtable(h, this)
return this
endmethod
method cache takes integer index, integer memory returns nothing
call SaveInteger(h, this, index, memory)
endmethod
method lookup takes integer index returns integer
return LoadInteger(h, this, index)
endmethod
method destroy takes nothing returns nothing
call FlushChildHashtable(h, this)
set rn[this] = rn[0]
set rn[0] = this
endmethod
endstruct
endlibrary
Feel free to comment.
Last edited: