我应该选择哪种数据结构以及原因(which data structure should i choose and why)

编程入门 行业动态 更新时间:2024-10-28 21:19:24
我应该选择哪种数据结构以及原因(which data structure should i choose and why)

我在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.

更多推荐

本文发布于:2023-07-09 00:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1082162.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据结构   哪种   原因   choose   structure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!