高效的列表数据结构

发布于 2024-11-03 02:05:04 字数 154 浏览 1 评论 0原文

我需要一个列表类型的数据结构来在项目中实现。实际上,它不一定是某种列表,但它必须很快,我将使用它来不断地从中插入/删除/检索数据(其他数据结构)。我可能会插入一些东西,搜索,再次插入,删除,再次搜索等等,所以动作是随机的。

我发现跳跃列表是迄今为止最快的,还有什么比这更快的呢?

I need a list-type data structure to implement in a project. Actually it doesn't necessary have to be some kind of list, but it has to be fast and I'm going to use to it to constantly insert/delete/retrieve data (other data structures) from it. I might insert something, search, insert again, delete, search again and so on, so actions are sort of random.

I found skip-lists the fastest so far, what is there faster than that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苍景流年 2024-11-10 02:05:04

很大程度上取决于您选择的语言。 C 为您提供了对最终数据结构的最大控制权,并且您最终将获得最快的实现之一。当然,这很容易搬起石头砸自己的脚。相当糟糕。 Python 抽象了很多列表数据结构,我发现它始终很快,但我也没有过分强调它。

我建议检查一下预构建的 C 库的最新内容,您可以将其重新用于您的任务。也许维基百科关于跳过列表的页面会引导您了解更多:http://en.wikipedia.org/wiki/Skip_list

数据结构是一门深奥的学科,需要有良好的大O表示法基础,以及当我们谈论“速度”和“效率”时它到底意味着什么,否则你将无法做出客观的比较。最后,一切都有利弊。选择一种最能模拟您的数据以及您打算如何操作数据的数据结构。如果您的任务相当随机,请回到设计阶段并问问自己如何在进入数据结构之前改进所发生的事情。也就是说,敲定你的算法,然后选择一个数据结构来补充它。

A great deal depends on your language of choice. C gives you the greatest control over your final data structure, and you will end up with one of the fastest implementations. With, of course, a very easy time shooting yourself in the foot. Rather badly. Python abstracts a lot of list data structure, and I find it is consistently fast, but I'm not stressing it too terribly either.

I would suggest a check of freshmeat for prebuilt C libraries that you can repurpose for your task. Perhaps wikipedia's page on skip lists will point you towards more: http://en.wikipedia.org/wiki/Skip_list

Data structures are a deep subject that requires a decent grounding in big O notation and exactly what it means when we talk about "speed" and "efficiency" or you will not be able to make an objective comparison. Finally, everything has trade offs. Pick a data structure that most closely models both your data, and how you intend to manipulate it. If you're tasks are rather random, step back into the design phase and ask your self how you can refine what happens before it gets to the data structure. That is, get your algorithm hammered out, and then pick a data structure to complement it.

若言繁花未落 2024-11-10 02:05:04

哈希表/hashmap/dictionary 听起来像你想要的。例如,Python 中的字典

A hashtable/hashmap/dictionary sounds like what you want. For example, dictionaries in Python.

半世晨晓 2024-11-10 02:05:04

您可以查看 BTree

You might look into the BTree

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文