Work :: Javascript Collections Libraries

- Code from the Map class
Download
- Languages:
- Javascript
- and HTML
The default Javascript collection, Array, has limitations and is difficult to use in many situations. This library contains implementations of more advanced data structures, and is meant to mimic the Java Collections API. Sample implementations are included, in the form of HTML pages for each Javascript object.
The objects included are:
- List
- Like an array, but provides methods for setting, inserting, and removing elements at a specified position.
- Set
-
Like List, except it is non-sequential and does not allow duplicate entries.
A Set depends on Map, and essentially represents a key-only view of a Map. Because Map stores its key/value pairs in a hash table, objects inserted into a Set are not guaranteed to maintain their insertion order.
- Map
-
A Javascript implementation of a hash table data structure. Stores elements as key/value pairs, and sorts them into buckets for fast search and retrieval.
The number of buckets used in a Map can be specified at creation. Each bucket represents a series of elements that are chained to avoid collisions. Elements are encapsulated key/value pairs that are added using put(key, value), and can be later retrieved using get(key). The bucket for a given key is determined by a hash code that is computed based on the key’s toString() method.
Download
- Copyright
- © 2001-2008
- Scott Martin.
- All Rights Reserved.
- Valid
- XHTML and
- CSS.