The Java language development team that created the original java.util
collection classes was fairly new
to object oriented design and collection frameworks and therefore made some common mistakes:
- using implementation inheritance instead of delegation (a
Stack
is not aVector
!) - exposing underlying implementations (e.g. hashtable, linked list, and tree)
- confusing ordered and sortable collections (e.g.
SortedSet
which is really an ordered set)
We forgive them, however, since they got a lot of things right 😉.
Subsequent additions to the java.util
package helped address some of these issues, but the designers were
somewhat constrained by the original mistakes to maintain backward compatibility.
This project starts with a clean slate. It defines a set of Java collection classes that are independent
of the java.util
collection classes but that still interoperate with them and also integrate with the
built-in Java language features that depend on the java.lang.Iterable
interface. These classes provide
the following nice features:
- simple, easy to understand interfaces
- self-optimizing implementations
- a well designed framework in which to work
The following highlights the main types of collections that this project provides:
- Bag - an ordered collection where duplicates are allowed
- Set - an ordered collection where duplicates are not allowed
- List - a sortable collection with implicit numberic indexes
- Map - a sortable collection with explicit arbitrary typed keys
- Stack - a collection that supports last in first out (LIFO)
- Queue - a collection that supports first in first out (FIFO)
For more detail on this project click on the following links:
To get started using these classes, include the following dependency in your maven pom.xml file:
<dependency>
<groupId>com.craterdog</groupId>
<artifactId>java-collection-framework</artifactId>
<version>x.y</version>
</dependency>
The source code, javadocs and jar file artifacts for this project are available from the Maven Central Repository. If your project doesn't currently use maven and you would like to, click here to get started down that path quickly.
The following flow chart provides a way to easily choose which collection type is right for your needs:
No need to worry about the underlying implementation of each type of collection, they are all self-optimizing and adjust automatically to varying read/update percentages.