java - Historical Arrays -
i've been approached task requires "historical" array references.
not sure if has correct name or not.
here's quick concept in visual form.
[nc] == no change array value (v1) (v2) (v3) (v4) (result) [10] -> [13] -> [12] -> [13] = 13 [5] -> [nc] -> [54] -> [nc] = 54 [6] -> [3] -> [61] -> [30] = 30 [7] -> [3] -> [27] -> [3] = 3 [23] -> [nc] -> [nc] -> [nc] = 23 [41] -> [48] -> [4] -> [48] = 48 [12] -> [nc] -> [2] -> [nc] = 2
i need able pull dataset array set, example (psudo code):
int[] results1 = arrayset.get(v2); system.out.println(results1[1]); // prints 5 int[] results2 = arrayset.get(v4); system.out.println(results2[1]); // prints 54
i have store 20 array sets second, reaching past 5 seconds.
so, 100 array sets in memory.
each array set contain around 200 values; amount quite large memory consumption.
my question you:
is there java implementation this, allow array values link older versions in array; or have make cloning whole array, , changing values need change? (plus suffer nasty memory drawback)
the total number of arrays need fixed, can preallocate them. use counter designate current array , cycle through.
you cannot avoid using memory, can avoid re-allocating new arrays. there complex data structures allow save 'unchanged' memory, case, seems keeping in fixed number of existing arrays enough.
i keep actual values in arrays, during update can copy old values , overwrite have changed.
if need know if current_array[i] changed respect old_array[i], can make quick comparison.
Comments
Post a Comment