c++ - Which container should I use for random access, cheap addition and removal (without de/allocation), with a known maximum size? -
i need lighter container must store till 128 unsigned int. must add, edit , remove each element accessing quickly, without allocating new memory every time (i know max 128).
such as:
add int 40 @ index 4 (1/128 item used) add int 36 @ index 90 (2/128 item used) edit value 42 element @ index 4 add int 36 @ index 54 (3/128 item used) remove element index 90 (2/128 item used) remove element index 4 (1/128 item used)
... , on. every time can iterate trought real number of elements added container, not , check if null or not.
during process, said, must not allocating/reallocating new memory, since i'm using app manage "audio" data , means glitch every time touch memory.
which container right candidate? sounds "indexes" queue.
as understand question, have 2 operations
insert/replace element value @ cell index
delete element @ cell index
and 1 predicate
is cell index occupied?
this array , bitmap. when insert/replace, stick value in array cell , set bitmap bit. when delete, clear bitmap bit. when ask, query bitmap bit.
Comments
Post a Comment