| java.lang.Object org.apache.xml.utils.SuballocatedIntVector
SuballocatedIntVector | public class SuballocatedIntVector (Code) | | A very simple table that stores a list of int. Very similar API to our
IntVector class (same API); different internal storage.
This version uses an array-of-arrays solution. Read/write access is thus
a bit slower than the simple IntVector, and basic storage is a trifle
higher due to the top-level array -- but appending is O(1) fast rather
than O(N**2) slow, which will swamp those costs in situations where
long vectors are being built up.
Known issues:
Some methods are private because they haven't yet been tested properly.
Retrieval performance is critical, since this is used at the core
of the DTM model. (Append performance is almost as important.)
That's pushing me toward just letting reads from unset indices
throw exceptions or return stale data; safer behavior would have
performance costs.
|
Constructor Summary | |
public | SuballocatedIntVector() Default constructor. | public | SuballocatedIntVector(int blocksize, int numblocks) Construct a IntVector, using the given block size and number
of blocks. | public | SuballocatedIntVector(int blocksize) Construct a IntVector, using the given block size and
the default number of blocks (32). |
Method Summary | |
public void | addElement(int value) Append a int onto the vector. | public int | elementAt(int i) Get the nth element. | final public int[][] | getMap() | final public int[] | getMap0() | public int | indexOf(int elem, int index) Searches for the first occurence of the given argument,
beginning the search at index, and testing for equality
using the equals method. | public int | indexOf(int elem) Searches for the first occurence of the given argument,
beginning the search at index, and testing for equality
using the equals method. | public void | removeAllElements() Wipe it out. | public void | setElementAt(int value, int at) Sets the component at the specified index of this vector to be the
specified object. | public void | setSize(int sz) Set the length of the list. | public int | size() Get the length of the list. |
NUMBLOCKS_DEFAULT | final protected static int NUMBLOCKS_DEFAULT(Code) | | The default number of blocks to (over)allocate by
|
m_SHIFTm_MASK | protected int m_SHIFTm_MASK(Code) | | Bitwise addressing (much faster than div/remainder
|
m_blocksize | protected int m_blocksize(Code) | | Size of blocks to allocate
|
m_buildCache | protected int m_buildCache(Code) | | "Shortcut" handle to most recently added row of m_map.
Very helpful during construction.
|
m_buildCacheStartIndex | protected int m_buildCacheStartIndex(Code) | | |
m_firstFree | protected int m_firstFree(Code) | | Number of ints in array
|
m_map | protected int m_map(Code) | | Array of arrays of ints
|
m_map0 | protected int m_map0(Code) | | "Shortcut" handle to m_map[0]. Surprisingly helpful for short vectors.
|
m_numblocks | protected int m_numblocks(Code) | | The number of blocks to (over)allocate by
|
SuballocatedIntVector | public SuballocatedIntVector()(Code) | | Default constructor. Note that the default
block size is currently 2K, which may be overkill for
small lists and undershootng for large ones.
|
SuballocatedIntVector | public SuballocatedIntVector(int blocksize, int numblocks)(Code) | | Construct a IntVector, using the given block size and number
of blocks. For efficiency, we will round the requested size
off to a power of two.
Parameters: blocksize - Size of block to allocate Parameters: numblocks - Number of blocks to allocate |
SuballocatedIntVector | public SuballocatedIntVector(int blocksize)(Code) | | Construct a IntVector, using the given block size and
the default number of blocks (32).
Parameters: blocksize - Size of block to allocate |
addElement | public void addElement(int value)(Code) | | Append a int onto the vector.
Parameters: value - Int to add to the list |
elementAt | public int elementAt(int i)(Code) | | Get the nth element. This is often at the innermost loop of an
application, so performance is critical.
Parameters: i - index of value to get value at given index. If that value wasn't previously set,the result is undefined for performance reasons. It may throw anexception (see below), may return zero, or (if setSize has previouslybeen used) may return stale data. throws: ArrayIndexOutOfBoundsException - if the index was _clearly_unreasonable (negative, or past the highest block). throws: NullPointerException - if the index points to a block that couldhave existed (based on the highest index used) but has never had anythingset into it.%REVIEW% Could add a catch to create the block in that case, or return 0.Try/Catch is _supposed_ to be nearly free when not thrown to. Do webelieve that? Should we have a separate safeElementAt? |
getMap | final public int[][] getMap()(Code) | | Return the m_map double array
the internal map of array of arrays |
getMap0 | final public int[] getMap0()(Code) | | Return the internal m_map0 array
the m_map0 array |
indexOf | public int indexOf(int elem, int index)(Code) | | Searches for the first occurence of the given argument,
beginning the search at index, and testing for equality
using the equals method.
Parameters: elem - object to look for Parameters: index - Index of where to begin search the index of the first occurrence of the objectargument in this vector at position index or later in thevector; returns -1 if the object is not found. |
indexOf | public int indexOf(int elem)(Code) | | Searches for the first occurence of the given argument,
beginning the search at index, and testing for equality
using the equals method.
Parameters: elem - object to look for the index of the first occurrence of the objectargument in this vector at position index or later in thevector; returns -1 if the object is not found. |
removeAllElements | public void removeAllElements()(Code) | | Wipe it out. Currently defined as equivalent to setSize(0).
|
setElementAt | public void setElementAt(int value, int at)(Code) | | Sets the component at the specified index of this vector to be the
specified object. The previous component at that position is discarded.
The index must be a value greater than or equal to 0 and less
than the current size of the vector.
Parameters: value - object to set Parameters: at - Index of where to set the object |
setSize | public void setSize(int sz)(Code) | | Set the length of the list. This will only work to truncate the list, and
even then it has not been heavily tested and may not be trustworthy.
length of the list |
size | public int size()(Code) | | Get the length of the list.
length of the list |
|
|