Package com.sosnoski.util.array

Type-specific growable array collection classes.

See:
          Description

Class Summary
ArrayBase Base class for type-specific growable array classes with any type of values (including primitive types).
ByteArray Growable byte array with type specific access methods.
CharArray Growable char array with type specific access methods.
DoubleArray Growable double array with type specific access methods.
IntArray Growable int array with type specific access methods.
ObjectArray Growable Object array with type specific access methods.
StringArray Growable String array with type specific access methods.
 

Package com.sosnoski.util.array Description

Type-specific growable array collection classes. The classes in this package are basically equivalent to type-specific versions of the standard java.util.Vector or newer java.util.ArrayList class. They support a few added methods (including direct conversion to a typed array with toArray()) and some minor interface differences. The standard public access methods in these classes are as follows:

Method SignatureFrom
int add(type)implementation class
void add(int, type)implementation class
void clear()ArrayBase
Object clone()implementation class
void ensureCapacity(int)GrowableBase
type get(int)implementation class
void remove(int)ArrayBase
void remove(int, int)ArrayBase
void set(int, type)implementation class
void setSize(int)ArrayBase
int size()ArrayBase
type[] toArray()implementation class
type[] toArray(int, int)implementation class

The ObjectArray class also provides a pair of toArray methods which allow the base element type of the array to be specified as something other than Object.

As with ArrayList, the access methods are unsynchronized for best performance. The user program must implement appropriate locking if multiple threads need to access an instance of these classes while that instance may be modified.

Collections of a primitive type and of a specific object type are both supported. All variations derive directly from the ArrayBase base class. To define a growable array of a new type, generally you can use one of the existing classes as a base and do a text substitution of the type names.

For instance, to define a growable array of instances of Thread just copy StringArray.java to a new file named ThreadArray.java, then do a global text substitution of "Thread" for "String" in the new file.

Primitive types are only slightly more complicated. byte and char versions are included, and short can be done using one of these as a base and just substituting the type name. The other primitive types, which are not promoted to int in expressions, can use the implementation for double as a base.



Company Web Site

XML Benchmark Home