Javascript data structure library

I would like to ask for recommendations from the JavaScript library / libraries that provide the implementation of some basic data structures, such as a priority queue, a map with arbitrary keys, attempts, graphs, etc. along with some algorithms that work on them.

I'm most interested in:

  • Full feature set,
  • Solution flexibility - this mainly applies to graphs. For example, I have to use the provided graphics,
  • Using the functionality of the language - again, it gives great flexibility,
  • Implementation implementation

EDIT

Well, I would like to note that I know that the following data structures can be implemented using js:

  • Map, if the key values ​​are either strings or numbers,
  • Set, (using map implementation),
  • The queue, although, as noted below, it is inefficient for some browsers,

At the moment, I am most interested in priority queues (not to be confused with next queues), implementation of graphs that are not very intrusive regarding the format of the input schedule. For example, they can use callbacks to move the chart structure rather than access to certain specific properties with fixed names.

+56
javascript algorithm data-structures
May 6 '11 at 9:32 a.m.
source share
9 answers

I recommend using the Closure Library (especially with the closure compiler).

Here you have a library with goog.structs data structures . The library contains:

goog.structs.AvlTree goog.structs.CircularBuffer goog.structs.Heap goog.structs.InversionMap goog.structs.LinkedMap goog.structs.Map goog.structs.PriorityQueue goog.structs.Set 

As an example, you can use unit test: goog.structs.PriorityQueueTest .

If you need to work with arrays, there is also an lib: goog.array array .

As noted in the comments, the source has moved to github.com/google/closure , and the new documentation location is google.imtqy.com/closure-library .

+32
Mar 19 '12 at 13:20
source share

You can try Buckets - this is a very complete JavaScript data structure library, which includes:

  • Linked list
  • Dictionary
  • Multilingual dictionary
  • Binary search tree
  • Stack
  • Queue
  • Set
  • a bag
  • Binary heap
  • Priority queue
+17
Jan 29 2018-12-21T00:
source share

Probably most of what you want is built into Javascript anyway or easily combined with built-in functionality (Javascript's own data structures are incredibly flexible). You may like JSClass .

Regarding the functional features of the language, underscore.js is where it is.

+3
May 6 '11 at 9:42 a.m. 2011-06-06
source share

I can help you with maps with arbitrary keys: my jshashtable does this, and there is also a hash set implementation built at the top.

+3
May 6 '11 at 10:24
source share

Effective Queue .

If you find more of them, could you add them to jswiki . Thank you. :)

+3
May 6 '11 at 10:34
source share

Is your javascript in app or webpage? If this is for the application, why not redirect the data structures to Redis ? There is a client for nodejs

Redis is an open source open source key repository. It is often referred to as a data structure server, because keys can contain strings, hashes, lists, sets, and sorted sets.

+1
Mar 22 '12 at 11:23
source share

Adding a link to the javascript user library, which provides priority queues, triasses, base graph processing, and other implementations for future links for visitors to this topic. Check dsjslib

+1
Aug 31 '14 at 14:10
source share

Especially for graph-like structures, I find graphlib very convenient:

https://github.com/cpettitt/graphlib/wiki/API-Reference

It is very straightforward, faster than other implementations that I tried, it has all the basic functions, popular graphical algorithms and JSON data export.

+1
Jul 15 '15 at 13:36
source share

data.js.

I don’t believe that the function is as rich as you want, but it has graphics, hashes and collections.

I would take this easy start, which you can extend.

As for what he offers, he is well written, efficient, and documented.

0
6 '11 at 9:49 Raynos
source share



All Articles