linked-map
A linked map data structure for ordered iteration and fast random access.
Install
Node.js
$ npm install --save linked-map
Vanilla JavaScript
Copy the distribution linked-map.js file into your project files, and include it as per usual:
Usage
> var LinkedMap = ; // Node.js > var map = ;> map; // Add an entry to the front of the linked list> map;> map; // Add an entry to the end of the linked list> map; // Update an existing entry without changing entry order. Use remove() first to update and change order.> map; // Get the value for a key3> map; // Get the first value in the linked list1> map; // Get the first key in the linked list'monkeys'> map; // Get the last value in the linked list4> map; // Get the last key in the linked list'cats'> mapsize; // Get the number of entries stored3> map; // Get an in-order list of keys known to the structure 'monkeys' 'dogs' 'cats' > map; // Get an in-order list of values known to the structure 1 3 4 > map; // Get the key following the given key in the linked list, if anynull> map; // Get the key following the given key, wrapping to the front if at the end'monkeys'> mapprevious'dogs'; // Get the value of the entry prior to the given key in the linked list, if any1> map;monkeys = 1dogs = 3cats = 4> map; // Get and remove the first value in the linked list1> map; // Get and remove the last value in the linked list4> map; // Remove the entry for the specified key and return the value.3> mapclear; // Remove all entries
Documentation
API documentation is available in the docs/
directory of the installed module directory.
Please see source code and unit tests for more details.
Contributing
Project source code is hosted on bitbucket: https://bitbucket.org/troykinsella/linked-map
Git repository: git@bitbucket.org:troykinsella/linked-map.git
Feel free to submit pull requests!
Reporting issues
Browse existing issues, and submit new issues here: https://bitbucket.org/troykinsella/linked-map/issues
Testing
Verify source code standards and run unit tests:
gulp test
Roadmap
- Minified vanilla JavaScript distributable
- Performance metrics
License
MIT © Troy Kinsella