See: Description
Class | Description |
---|---|
AbstractBooleanList |
Abstract base class for resizable lists holding
boolean elements; abstract. |
AbstractByteList |
Abstract base class for resizable lists holding
byte elements; abstract. |
AbstractCharList |
Abstract base class for resizable lists holding
char elements; abstract. |
AbstractCollection |
Abstract base class for resizable collections holding objects or primitive data types such as
int , float , etc. |
AbstractDoubleList |
Abstract base class for resizable lists holding
double elements; abstract. |
AbstractFloatList |
Abstract base class for resizable lists holding
float elements; abstract. |
AbstractIntList |
Abstract base class for resizable lists holding
int elements; abstract. |
AbstractList |
Abstract base class for resizable lists holding objects or primitive data types such as
int , float , etc. |
AbstractLongList |
Abstract base class for resizable lists holding
long elements; abstract. |
AbstractShortList |
Abstract base class for resizable lists holding
short elements; abstract. |
BooleanArrayList |
Resizable list holding
boolean elements; implemented with arrays. |
ByteArrayList |
Resizable list holding
byte elements; implemented with arrays. |
CharArrayList |
Resizable list holding
char elements; implemented with arrays. |
DistinctNumberList |
Resizable compressed list holding numbers; based on the fact that a number from a large list with few distinct values need not take more than log(distinctValues) bits; implemented with a MinMaxNumberList.
|
DoubleArrayList |
Resizable list holding
double elements; implemented with arrays. |
FloatArrayList |
Resizable list holding
float elements; implemented with arrays. |
IntArrayList |
Resizable list holding
int elements; implemented with arrays. |
LongArrayList |
Resizable list holding
long elements; implemented with arrays. |
MinMaxNumberList |
Resizable compressed list holding numbers; based on the fact that a value in a given interval need not take more than log(max-min+1) bits; implemented with a cern.colt.bitvector.BitVector.
|
ObjectArrayList |
Resizable list holding
Object elements; implemented with arrays. |
ShortArrayList |
Resizable list holding
short elements; implemented with arrays. |
SimpleLongArrayList |
Resizable list holding
long elements; implemented with arrays; not efficient; just to demonstrate which methods you must override to implement a fully functional list. |
cern.colt.matrix
.
The list package offers flexible object oriented abstractions modelling dynamically resizing lists holding objects or primitive data types such as int, double, etc. It is designed to be scalable in terms of performance and memory requirements.
Features include:
File-based I/O can be achieved through the standard Java built-in serialization
mechanism. All classes implement the Serializable
interface.
However, the toolkit is entirely decoupled from advanced I/O. It provides data
structures and algorithms only.
This toolkit borrows concepts and terminology from the Javasoft Collections framework written by Josh Bloch and introduced in JDK 1.2.
Lists are fundamental to virtually any application. Large scale resizable lists are, for example, used in scientific computations, simulations database management systems, to name just a few.
A list is a container holding elements that can be accessed via zero-based indexes. Lists may be implemented in different ways (most commonly with arrays). A resizable list automatically grows as elements are added. The lists of this package do not automatically shrink. Shrinking needs to be triggered by explicitly calling trimToSize() methods.
Growing policy: A list implemented with arrays initially has a certain initialCapacity - per default 10 elements, but customizable upon instance construction. As elements are added, this capacity may nomore be sufficient. When a list is automatically grown, its capacity is expanded to 1.5*currentCapacity. Thus, excessive resizing (involving copying) is avoided.
Any list can be copied. A copy is equal to the original but entirely independent of the original. So changes in the copy are not reflected in the original, and vice-versa.
Class naming follows the schema <ElementType><ImplementationTechnique>List.
For example, we have a DoubleArrayList
, which is a list
holding double elements implemented with double[] arrays.
The classes for lists of a given value type are derived from a common abstract
base class tagged Abstract<ElementType>List. For example,
all lists operating on double elements are derived from AbstractDoubleList
,
which in turn is derived from an abstract base class tying together all lists
regardless of value type, AbstractList
, which finally
is rooted in grandmother AbstractCollection
. The abstract
base classes provide skeleton implementations for all but few methods. Experimental
data layouts (such as compressed, sparse, linked, etc.) can easily be implemented
and inherit a rich set of functionality. Have a look at the javadoc tree
view to get the broad picture.
The following snippet fills a list, randomizes it, extracts the first half of the elements, sums them up and prints the result. It is implemented entirely with accessor methods.
int s = 1000000; |
For efficiency, all classes provide back doors to enable getting/setting the backing array directly. In this way, the high level operations of these classes can be used where appropriate, and one can switch to []-array index notations where necessary. The key methods for this are public <ElementType>[] elements() and public void elements(<ElementType>[]). The former trustingly returns the array it internally keeps to store the elements. Holding this array in hand, we can use the []-array operator to perform iteration over large lists without needing to copy the array or paying the performance penalty introduced by accessor methods. Alternatively any JAL algorithm (or other algorithm) can operate on the returned primitive array. The latter method forces a list to internally hold a user provided array. Using this approach one can avoid needing to copy the elements into the list.
As a consequence, operations on primitive arrays, Colt lists and JAL algorithms can freely be mixed at zero-copy overhead.
Note that such special treatment certainly breaks encapsulation. This functionality is provided for performance reasons only and should only be used when absolutely necessary. Here is the above example in mixed notation:
int s = 1000000; |
Or even more compact using lists as algorithm objects:
int s = 1000000; |
The quicksorts and mergesorts are the JDK 1.2 V1.26 algorithms, modified as necessary to operate on the given data types.
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.