Java Notes
Alternative Data Structures
Packages have been developed outside of standard Java for additional functionality.
The following free, GPL, packages fill in missing parts of the
Collections package, but remain consistent with the basic Java
List
, Map
, Set
, etc
interfaces. These packages address several shortcomings of the
Java Collections data structures: lack of support for primitive data types,
lack of support for generics, etc.
Below are a few that I've looked at in the past. There are others, but unless you have a real need, stick with the standard Java data collection classes.
- Google Collections
- Google allows employees to use 20% of their time on work on their own projects, and one of these has been the Google Collections project, which has produced some very nice additional data structures. You can read about who is behind this project in the JavaLobby article What is the Google Collections Library?. This is the first place I would look for data structures beyond the standard library.
- Larvalabs Collections
- This is the generic version of the Apache Jakarta Commons Collections below.
- Apache Jakarta Commons Collections Package
- Has "special-purpose implementations of Lists and Maps for fast access" and "methods to test or create typical set-theory properties of collections such as union, intersection, and closure". It also has some implementations of "bags", which are maps that count the number of times an element is added. This has a number of extremely good extensions, but the Google Collections library is probably a better choice now. Free, open source.
- GNU Trove for Java
- Provides free, fast, lightweight implementations of the Java Collections API as well as collections support for primitive types.
- Colt
- "Colt provides a set of open source libraries for high performance scientific and technical computing in Java."
- Glazed Lists
- "Glazed Lists is an application of the Decorator and Observer patterns over Java Lists. It provides transforming views of a source list that respond to changes as they occur. These views can be layered to provide simple and powerful manipulation of the source data." Some GUI component models are also defined to make it easy to use them in a Swing GUI.