Overview
LispVector Information
Defined as: lisp.common.type.Vector
Parent Types:
LispArray, Sequence
A
LispVector in
CLforJava is defined as a
LispArray with one dimension. A
LispVector's size is represented by a non-negative
Fixnum. A fill pointer may be specified as well.
LispVector is a subtype of
LispArray.
What is a fill pointer?
From the
HyperSpec :
fill pointer n. (of a vector) an integer associated with a vector that represents the index above which no elements are active. (A fill pointer is a non-negative integer no larger than the total number of elements in the vector. Not all vectors have fill pointers.)
How is the type LispVector represented in Java?
The
LispVector (lisp.common.type.Vector) in
CLforJava is implemented using java.util.ArrayList to handle resizing
LispVector as well as providing much backend functionality from the Collections framework. The choice of
ArrayList? comes from the fact that lisp has many specialized types that should be used for performance, as the
ArrayList? is slower, but provides a more generic and feature rich Vector, without reinventing the wheel. See relevant discussions for speed analysis. The fill pointer will be represented by a class called
FillPointer? .
How are Vectors created?
The
LispVector type (lisp.common.type.Vector) will contain a Factory class and method (newInstance) within it's interface definition. This Factory will determine whether or not to create a
LispVector or delegate the creation to a more specific type such as
LispString for performance reasons. Possible instantiations include:
public static Vector newInstance(int dimensions, java.lang.Class elementType, Object[] initialContents, boolean adjustable,
java.lang.Integer fillPointer)
public static Vector newInstance(int dimensions, java.lang.Class elementType, T initialElement, boolean adjustable,
java.lang.Integer fillPointer)
public static Vector newInstance(int dimensions, java.lang.Class elementType, boolean adjustable, java.lang.Integer fillPointer,
Array displacedTo, int displacedIndexOffset)
public static Vector newInstance(int dimensions, java.lang.Class elementType, boolean adjustable, java.lang.Integer fillPointer)
Information on the parameters:
int dimensions - The number of dimensions (will always be 1)
java.lang.Class elementType - type of the elements that will be in the vector
T initialElement - the type of the first element in the vector
Object[] initialContents - an array of the initial contents that will be placed in the vector
boolean adjustable - Determines if the array can grow and shrink in size
java.lang.Integer fillPointer - Allows for the fill pointer to be arbitrarily placed (as opposed to starting at the first element and moving up)
Array displacedTo - Link to the array in which the vector will be stored (as opposed to its own storage)
int displacedIndexOffset - Unknown at the moment.
How is size reallocation handled with type LispVector?
LispVector size reallocation will be handled by the java native type java.util.ArrayList.
Relevant Discussions
Performance analysis of java types
Relevant Links
HyperSpec Vector
CLtL Vector
BitVector
TypeSystem
Functions
--
NeilLee - 15 Feb 2007