Im writing timers manager in C, which involves:
- creating new timer
- removing timers
- removing dead timer
- freezing timers
- and all the other stuff which i did not yet think about.
The key is – amount of memory should be as small as possible.
At first i thought about linked list, but if i remove some of the middle part, i should rebuild list, which can take some time. Typical dynamic array is the same – i should be carefull with pointers to not miss some of them, when Im rebuliding that structure.
Any ideas ?
Thx for all answer
You don’t need to rebuild anything when removing from a linked list. It’s an
O(1)op. No matter what structure you’ll choose you’ll probably have to be careful about pointers.