mikera.indexz
Class GrowableIndex
- java.lang.Object
-
- mikera.indexz.AIndex
-
- mikera.indexz.GrowableIndex
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<AIndex>, java.lang.Iterable<java.lang.Integer>
public class GrowableIndex extends AIndex
An index implementation that supports appending, allowing the Index to be enlarged.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description GrowableIndex()GrowableIndex(int initialCapacity)GrowableIndex(int[] values)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidappend(int i)voidcheckedAppend(int i)Appends to a growable index, ensuring that the added index is higher than the last indexvoidcopyTo(int[] array, int offset)static GrowableIndexcreate(AIndex source)Creates a GrowableVector with the specified index values includedGrowableIndexexactClone()intget(int i)Gets the index value at position iintinclude(int i)Includes a value in a distinct, sorted growable index.intindexPosition(int x)Looks up an index value in the index, returning its position or -1 if not found Index must be both sorted and distinct.intlast()Gets the last index value in this index.intlength()Returns the length of this index listintseekPosition(int i)Returns the position at which an index value exists or should be inserted at in an index Index must be both sorted and distinct.voidset(int i, int value)static GrowableIndexwrap(int[] indexes)Creates a GrowableVector with the specified index values included-
Methods inherited from class mikera.indexz.AIndex
clone, compareTo, compose, contains, contains, containsSorted, equals, equals, hashCode, isDistinct, isDistinctSorted, isFullyMutable, isPermutation, isSorted, iterator, maxIndex, minIndex, reverse, sort, swap, toArray, toIndex, toList, toString
-
-
-
-
Constructor Detail
-
GrowableIndex
public GrowableIndex()
-
GrowableIndex
public GrowableIndex(int initialCapacity)
-
GrowableIndex
public GrowableIndex(int[] values)
-
-
Method Detail
-
create
public static GrowableIndex create(AIndex source)
Creates a GrowableVector with the specified index values included- Parameters:
source-- Returns:
-
wrap
public static GrowableIndex wrap(int[] indexes)
Creates a GrowableVector with the specified index values included- Parameters:
source-- Returns:
-
get
public int get(int i)
Description copied from class:AIndexGets the index value at position i
-
length
public int length()
Description copied from class:AIndexReturns the length of this index list
-
append
public void append(int i)
-
checkedAppend
public void checkedAppend(int i)
Appends to a growable index, ensuring that the added index is higher than the last index- Parameters:
i-
-
indexPosition
public int indexPosition(int x)
Description copied from class:AIndexLooks up an index value in the index, returning its position or -1 if not found Index must be both sorted and distinct.- Specified by:
indexPositionin classAIndex- Returns:
-
exactClone
public GrowableIndex exactClone()
- Specified by:
exactClonein classAIndex
-
last
public int last()
Description copied from class:AIndexGets the last index value in this index. Throws an exception if the index is empty
-
include
public int include(int i)
Includes a value in a distinct, sorted growable index.- Parameters:
i-- Returns:
- The position at which the value is added (or already exists)
-
seekPosition
public int seekPosition(int i)
Description copied from class:AIndexReturns the position at which an index value exists or should be inserted at in an index Index must be both sorted and distinct.- Overrides:
seekPositionin classAIndex- Returns:
- The target position in the index, which will satisfy 0 <= position <= this.length()
-
-
DMelt 3.0 © DataMelt by jWork.ORG