Javascript data structures library

I recommend to use Closure Library (especially with closure compiler).

Here you have a library with data structures goog.structs. 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 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.


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


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.


You can try Buckets is a very complete JavaScript data structure library that includes:

  • Linked List
  • Dictionary
  • Multi Dictionary
  • Binary Search Tree
  • Stack
  • Queue
  • Set
  • Bag
  • Binary Heap
  • Priority Queue