As of August 2024, the Closure Library has been sunsetted as it's "no longer meeting the needs of modern Javascript Development, see the deprecation notice and suggested alternatives, but relevant to this question:
For many parts of the library (goog.array, goog.dom, goog.events, goog.json, etc), JavaScript's built-in solutions should be sufficient.
For many special-purpose packages (math, data structures, other algorithms), a small focused library is often better than Closure's monolithic approach.
Original answer
I recommend to use Closure Library (especially with closure compiler).
Here you have a library with data structures goog.structs.
The library contains:
Probably most of what you want is built-in to Javascript in one way or another, or easy to put together with built-in functionality (native Javascript data structures are incredibly flexible). You might like JSClass.
As for the functional features of the language, underscore.js is where it's at..
Adding a link to a custom javascript library which provides Priority Queues, Tries, Basic Graph processing and other implementation, for future reference of the visitors to this thread . Check out dsjslib
Is your javascript in an application, or a web page? If it's for an application, why not outsource the data structures to Redis? There's a client for nodejs
Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
发布评论
评论(9)
编辑
截至 2024 年 8 月,Closure 库已被废弃,因为它“不再满足现代 Javascript 开发的需求,请参阅 弃用通知和建议的替代方案,但与此问题相关:
原始答案
我建议使用闭包库(特别是使用闭包编译器)。
这里有一个包含数据结构 goog.structs 的库。
该库包含:
例如,您可以使用单元测试: goog.structs.PriorityQueueTest。
如果您需要处理数组,还有一个数组库: goog.array。
正如评论中所述,来源已移至 github.com/google/closure 并且文档的新位置是:google.github.io/closure-library 。
Edit
As of August 2024, the Closure Library has been sunsetted as it's "no longer meeting the needs of modern Javascript Development, see the deprecation notice and suggested alternatives, but relevant to this question:
Original answer
I recommend to use Closure Library (especially with closure compiler).
Here you have a library with data structures goog.structs.
The library contains:
As example you can use unit test: goog.structs.PriorityQueueTest.
If you need to work on arrays, there's also an array lib: goog.array.
As noted in comments, the source has moved to github.com/google/closure and the documentation's new location is: google.github.io/closure-library.
你可以尝试 Buckets 是一个非常完整的 JavaScript 数据结构库,其中包括:
You can try Buckets is a very complete JavaScript data structure library that includes:
也许您想要的大部分功能都以某种方式内置于 Javascript,或者易于与内置功能组合在一起(原生 Javascript 数据结构非常灵活)。您可能喜欢 JSClass。
至于该语言的功能特性,underscore.js 就是它所在的地方。
Probably most of what you want is built-in to Javascript in one way or another, or easy to put together with built-in functionality (native Javascript data structures are incredibly flexible). You might like JSClass.
As for the functional features of the language, underscore.js is where it's at..
我可以帮助您使用任意键的地图:我的 jshashtable 可以做到这一点,而且还有建立在其之上的哈希集实现。
I can help you with the maps with arbitrary keys: my jshashtable does this, and there is also a hash set implementation built on top of it.
高效队列。
如果您发现更多此类内容,请将它们添加到 jswiki 中。谢谢。 :)
Efficient queue.
If you find more of these, could you please add them to jswiki. Thanks. :)
特别是对于类似图形的结构,我发现 graphlib 非常方便:
https://github.com/ cpettitt/graphlib/wiki/API-Reference
它非常简单,比我尝试过的其他实现更快,具有所有基本功能、流行的图形算法和 JSON 数据导出。
Especially for graph-like structures, i find graphlib very convenient:
https://github.com/cpettitt/graphlib/wiki/API-Reference
It is very straight-forward, faster than other implementations I tried, has all the basic features, popular graph-algorithms and a JSON data export.
添加一个自定义 JavaScript 库的链接,该库提供优先级队列、尝试、基本图形处理和其他实现,以供该线程的访问者将来参考。查看 dsjslib
Adding a link to a custom javascript library which provides Priority Queues, Tries, Basic Graph processing and other implementation, for future reference of the visitors to this thread . Check out dsjslib
data.js。
我不认为它的功能如您想要的那么丰富,但它有图表、哈希值和集合。
我认为这是一个轻量级的开始,您可以继续扩展。
至于它提供的功能,它写得很好,高效且有记录。
data.js.
I don't believe it's as feature rich as you want but it has graphs, hashes and collections.
I would take this a lightweight start that you can extend on.
As for what it does offer, it's well written, efficient and documented.
您的 javascript 是在应用程序中还是在网页中?如果是用于应用程序,为什么不将数据结构外包给 Redis 呢?有一个 nodejs 客户端
Is your javascript in an application, or a web page? If it's for an application, why not outsource the data structures to Redis? There's a client for nodejs