Skip to main content

javascript data structures library



I'd like to ask for recommendation of JavaScript library/libraries that supply an implementation of some basic data structures such as a priority queue, map with arbitrary keys, tries, graphs, etc. along with some algorithms that operate on them.





I'm mostly interested in:





  • The set of features covered,



  • Flexibility of the solution - this mostly applies to graphs. For example do I have to use a supplied graph implementation,



  • Use of functional features of the language - again it sometimes gives greater flexibility,



  • Performance of the implementation







EDIT





Ok, I'd like to point out that I'm aware that it's possible to implement using js the following data structures:





  • A map, if key values are either strings or numbers,



  • A set, (using a map implementation),



  • A queue, although as was pointed out below, it's inefficient on some browsers,







At the moment I'm mostly interested in priority queues (not to confuse with regular queues), graph implementations that aren't very intrusive as to the format of the input graph. For example they could use callbacks to traverse the structure of the graph rather than access some concrete properties with fixed names.



Source: Tips4all

Comments

  1. You can try Buckets is a very complete javascript data structure library and has everything you need.

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

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

    ReplyDelete
  4. Efficient queue.

    If you find more of these, could you please add them to jswiki. Thanks. :)

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

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

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.