The generic collection library

Bruce Eckel’s Thinking in Java Contents | Prev | Next

You’ve
seen in this chapter that the standard Java library has some fairly useful
collections, but far from a complete set. In addition, algorithms like sorting
are not supported at all. One of the strengths of C++ is its libraries, in
particular the Standard
Template Library

(STL) that provides a fairly full set of collections as well as many algorithms
like sorting and searching that work with those collections. Based on this
model, the
ObjectSpace
company was inspired to create the
Generic
Collection Library

for
Java
(formerly
called the
Java
Generic Library
,
but the abbreviation JGL is still used – the old name infringed on
Sun’s copyright), which follows the design of the STL as much as possible
(given the differences between the two languages). The JGL seems to fulfill
many, if not all, of the needs for a collection library, or as far as one could
go in this direction without C++’s template mechanism. The JGL includes
linked lists, sets, queues, maps, stacks, sequences, and iterators that are far
more functional than
Enumeration,
as well as a full set of

algorithms
such as searching and sorting. ObjectSpace also made, in some cases, more
intelligent design decisions than the Sun library designers. For example, the
methods in the JGL collections are
not
final so it’s easy to inherit and override those methods.

More by Author

Must Read