Primitive Collections for Java

Latest release is: pcj 1.2, August 27, 2003

Søren Bak


August 27, 2003: pcj v1.2 released

March 7, 2003: Bugfix release 1.1.1

March 5, 2003: pcj v1.1 released

February 17, 2003: PCJ 1.0 released

January 15, 2003: PCJ 1.0 beta 1 released

January 7, 2003: PCJ 1.0 alpha 2 released

December 29, 2002: Primitive Collections for Java 1.0 alpha 1 released

Downloads & documentation

Download the latest release, or view the release notes. You can view the API documentation and developer's guide online.


Primitive Collections for Java (PCJ) is a set of collection classes for primitive data types in Java. The goal is to provide an efficient alternative to the Java Collections Framework (JCF) when using primitive data types, such as int, boolean, or double. Some of its main features are:

Interface hierarchy for all primitive types. PCJ provides symmetrical interface hierarchy for each of the primitive Java data types: boolean, char, byte, short, int, long, float, and double. Each hierarchy includes interfaces for general collections, sets, lists, and maps. To increase the learning rate and make adaptions easier to implement, each hierarchy resembles the interfaces of JCF as close as possible.

Full interoperability with JCF classes. Each of the main collection interfaces is accompanied by adapters to and from the corresponding JCF collections. Adaption is made convenient by factory methods in the Adapter class.

Specialized implementations. While JCF and many of the classes in PCJ perform well in the general case, much can be saved by choosing a more specialized and restricted implementation. PCJ provides a number of such classes, including range based sets (see for example CharRangeSet) and bit array based sets (see for example IntBitSet).

High Performance. Benchmarks show good performance results for PCJ collections. The benchmark results are available in the the developer's guide.


Any kind of constructive feedback is welcome, and will be credited properly. If you use PCJ for a project, I will ask you to post a link or a note to the forum pages at SourceForge or send me an e-mail. This is of course not a requirement, but it will help determine the future direction of PCJ.

Bugs can be reported to the bug tracker at SourceForge.

You are always welcome to request new features using the feature request tracker at SourceForge.


Matt Ayres found and reported some nasty bugs in the map implementations.

Gabriel Jones suggested and discussed with me how to create collection instances from arrays and strings. He also suggested the addition of the ObjectKeyTMap classes.

Morten Wittrock suggested that a guide and examples was included. (The necessity of this was not clear to me due to the close resemblance of PCJ to JCF.) He also suggested support for JDK1.3 and some simplifications of the code.

Jonathan Oexner suggested and discussed with me validation of adapted JCF collections.

Joshua Bloch provided the basic interface design of the Java Collections Framework on which PCJ is based.

Other collections libraries

Besides PCJ, there are a number of other primitive collection libraries around. If you intend to use a primitive collections library in your project, you should definitely have a look at the others as well. Some of them are listed below:

GNU Trove High performance collections for Java Objects and primitive types. GNU Trove is created by Eric D. Friedman.

Colt Open Source Libraries for High Performance Scientific and Technical Computing in Java. Colt is created by Wolfgang Hoschek.

tclib tclib is a library/framework for type-specific collections in Java. tclib is created by Dennis Sosnoski.

Last updated: August 27, 2003

This project is hosted at SourceForge: Logo