我在C中写定时器经理,其中涉及:
创建新计时器 删除计时器 删除死计时器 冻结计时器 以及我还没有想过的所有其他东西。关键是 - 内存量应尽可能小。 起初我想到链表,但如果我删除一些中间部分,我应该重建列表,这可能需要一些时间。 典型的动态数组是相同的 - 我应该小心指针,不要错过它们中的一些,当我反叛那个结构。
有任何想法吗 ?
感谢所有答案
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
最满意答案
从链接列表中删除时,您无需重建任何内容。 这是一个O(1) op。 无论你选择什么结构,你都可能需要小心指针。
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.
更多推荐
发布评论