|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.itc.irst.tcc.ties.util.IndexList
The IndexList class implements a growable sorted list of indexes.
The list is sorted into increasing order; the order is assured by construction. A new
index is added into the list if it is greater than the last index present into the list;
othewise it is discarted. Like an array, components that can be accessed using
an integer index.
Each IndexList tries to optimize storage management by maintaining
a capacity and a capacityIncrement. The capacity
is always at least as large as the IndexList size; it is usually larger
because as components are added to the IndexList, the IndexList's
storage increases in chunks the size of capacityIncrement. An
application can increase the capacity of a IndexList before inserting
a large number of components; this reduces the amount of incremental reallocation.
| Field Summary | |
protected int |
capacityIncrement
The amount by which the capacity of the IndexList is automatically
incremented when its size becomes greater than its capacity. |
protected int |
elementCount
The number of valid components in the IndexList. |
protected int[] |
elementData
The array buffer into which the components of the ints are stored. |
(package private) static org.apache.log4j.Logger |
logger
Define a static logger variable so that it references the Logger instance named IndexList. |
| Constructor Summary | |
IndexList()
Constructs an empty IndexList. |
|
IndexList(int initialCapacity)
Constructs an empty IndexList with the specified initial capacity. |
|
IndexList(int initialCapacity,
int capacityIncrement)
Constructs an empty IndexList with the specified initial capacity and
capacity increment. |
|
| Method Summary | |
void |
add(int index)
Adds the specified index to the end of this IndexList,
increasing its size by one. |
int |
capacity()
Returns the current capacity of this IndexList. |
boolean |
contains(int elem)
Tests if the specified object is a component in this IndexList. |
void |
copyInto(int[] anArray)
Copies the components of this IndexList into the specified array.
|
IndexList |
duplicate()
Returns an IndexList with the components of this IndexList
incremented by inc. |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this IndexList, if necessary, to ensure
that it can hold at least the number of components specified by
the minimum capacity argument. |
private void |
ensureCapacityHelper(int minCapacity)
This implements the unsynchronized semantics of ensureCapacity. |
int |
firstIndex()
Returns the first index (the item at index 0) of this list. |
int[] |
getArray()
Copies the components of this IndexList into the specified array.
|
IndexList |
getIntersection(IndexList indexList)
Returns the intersection between this object and the specified index list. |
IndexList |
getIntersection(IndexList indexList,
int inc1,
int inc2)
Returns the intersection between this object and the specified index list. |
IndexList |
getIntersection1(IndexList l2)
|
IndexList |
getIntersection1(IndexList l2,
int inc1,
int inc2)
|
IndexList |
getUnion(IndexList indexList)
Returns the union between this object and the specified index list. |
IndexList |
incValue(int inc)
Returns an IndexList with the components of this IndexList
incremented by inc. |
IndexList |
incValue(int inc,
int min,
int max)
Returns an IndexList with the components of this IndexList
incremented by inc. |
int |
indexAt(int index)
Returns the index at the specified position in this list. |
int |
indexOf(int elem)
Searches for the first occurence of the given argument, testing for equality using the equals method. |
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. |
boolean |
isEmpty()
Tests if this IndexList has no components. |
int |
lastIndex()
Returns the last index of this list. |
int |
lastIndexOf(int elem)
Returns the index of the last occurrence of the specified object in this IndexList. |
int |
lastIndexOf(int elem,
int index)
Searches backwards for the specified object, starting from the specified index, and returns an index to it. |
int |
search(int index)
|
int |
search(int index,
int inc)
|
void |
setIndexAt(int obj,
int index)
Sets the component at the specified index of this
vector to be the specified object. |
int |
size()
Returns the number of components in this IndexList. |
java.lang.String |
toString()
Returns a string representation of this IndexList. |
void |
trim()
Trims the capacity of this IndexList to be the IndexList's current
size. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
static org.apache.log4j.Logger logger
IndexList.
protected int[] elementData
IndexList is the length of this array buffer.
protected int elementCount
IndexList.
protected int capacityIncrement
IndexList is automatically
incremented when its size becomes greater than its capacity. If
the capacity increment is 0, the capacity of the
IndexList is doubled each time it needs to grow.
| Constructor Detail |
public IndexList(int initialCapacity,
int capacityIncrement)
IndexList with the specified initial capacity and
capacity increment.
initialCapacity - the initial capacity of the IndexList.capacityIncrement - the amount by which the capacity is
increased when the IndexList overflows.public IndexList(int initialCapacity)
IndexList with the specified initial capacity.
initialCapacity - the initial capacity of the IndexList.public IndexList()
IndexList.
| Method Detail |
public final void copyInto(int[] anArray)
IndexList into the specified array.
The array must be big enough to hold all the objects in this IndexList.
anArray - the array into which the components get copied.public final int[] getArray()
IndexList into the specified array.
The array must be big enough to hold all the objects in this IndexList.
public final IndexList incValue(int inc,
int min,
int max)
IndexList with the components of this IndexList
incremented by inc.
inc - the amount each component must be incremented.min - the min value allowed, inclusive..max - the max value allowed, exclusive.
IndexList incremented by
incinto the specified array.public final IndexList duplicate()
IndexList with the components of this IndexList
incremented by inc.
IndexList incremented by
incinto the specified array.public final IndexList incValue(int inc)
IndexList with the components of this IndexList
incremented by inc.
inc - the amount each component must be incremented.
IndexList incremented by
incinto the specified array.public final void trim()
IndexList to be the IndexList's current
size. An application can use this operation to minimize the
storage of a IndexList.
public final void ensureCapacity(int minCapacity)
IndexList, if necessary, to ensure
that it can hold at least the number of components specified by
the minimum capacity argument.
minCapacity - the desired minimum capacity.private void ensureCapacityHelper(int minCapacity)
public final int capacity()
IndexList.
IndexList.public final int size()
IndexList.
IndexList.public final boolean isEmpty()
IndexList has no components.
true if this IndexList has no components;
false otherwise.public final boolean contains(int elem)
IndexList.
elem - an object.
true if the specified object is a component in
this IndexList; false otherwise.public final int indexOf(int elem)
equals method.
elem - an object.
IndexList; returns -1 if the object is not found.
public final int indexOf(int elem,
int index)
index, and testing for equality using
the equals method.
elem - an object.index - the index to start searching from.
IndexList at position index or later in the
IndexList; returns -1 if the object is not found.public final int lastIndexOf(int elem)
IndexList.
elem - the desired component.
IndexList; returns -1 if the object is not found.
public final int lastIndexOf(int elem,
int index)
elem - the desired component.index - the index to start searching from.
IndexList at position less than index in the IndexList;
-1 if the object is not found.public final int indexAt(int index)
public final int firstIndex()
java.util.NoSuchElementException - if this IndexList has no components.public final int lastIndex()
java.util.NoSuchElementException - if this IndexList is empty.
public final void setIndexAt(int obj,
int index)
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.
obj - what the component is to be set to.index - the specified index.
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.public final void add(int index)
IndexList,
increasing its size by one. The capacity of this IndexList is
increased if its size becomes greater than its capacity. if the new index
is greater than the last index present into the list is added; othewise is
discarted.
index - the component to be added.public IndexList getIntersection1(IndexList l2)
public IndexList getIntersection1(IndexList l2,
int inc1,
int inc2)
public IndexList getIntersection(IndexList indexList)
public IndexList getIntersection(IndexList indexList,
int inc1,
int inc2)
public IndexList getUnion(IndexList indexList)
public final java.lang.String toString()
IndexList.
IndexList.public int search(int index)
public int search(int index,
int inc)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||