mikera.indexz
Class AIndex
- java.lang.Object
-
- mikera.indexz.AIndex
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<AIndex>, java.lang.Iterable<java.lang.Integer>
- Direct Known Subclasses:
- ComputedIndex, GrowableIndex, Index
public abstract class AIndex extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<AIndex>, java.lang.Iterable<java.lang.Integer>
Abstract base class for a list of integer indexes- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description AIndex()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description AIndexclone()intcompareTo(AIndex a)Indexcompose(AIndex a)Composes this index with a second index, returning a new index.booleancontains(Index inds)booleancontains(int index)Returns true if the index contains a specific value.booleancontainsSorted(int index)Returns true if the index contains a specific value.voidcopyTo(int[] array, int offset)booleanequals(AIndex o)booleanequals(java.lang.Object o)abstract AIndexexactClone()abstract intget(int i)Gets the index value at position iinthashCode()abstract 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.booleanisDistinct()Returns true if this Index contains only distinct integer indicesbooleanisDistinctSorted()Returns true if this index is distinct and sorted (in strictly increasing order)booleanisFullyMutable()booleanisPermutation()Returns true if this index represents a permutation of positions 0..length-1booleanisSorted()Returns true if this index is sorted (in increasing order)IndexIteratoriterator()Gets an iterator over all elements of this indexabstract intlast()Gets the last index value in this index.abstract intlength()Returns the length of this index listintmaxIndex()intminIndex()voidreverse()intseekPosition(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.abstract voidset(int i, int value)voidsort()Sorts the index in place.voidswap(int i, int j)int[]toArray()IndextoIndex()java.util.List<java.lang.Integer>toList()java.lang.StringtoString()
-
-
-
Method Detail
-
get
public abstract int get(int i)
Gets the index value at position i- Parameters:
i-- Returns:
-
length
public abstract int length()
Returns the length of this index list- Returns:
-
set
public abstract void set(int i, int value)
-
isFullyMutable
public boolean isFullyMutable()
-
copyTo
public void copyTo(int[] array, int offset)
-
toArray
public int[] toArray()
-
toIndex
public Index toIndex()
-
toList
public java.util.List<java.lang.Integer> toList()
-
swap
public void swap(int i, int j)
-
reverse
public void reverse()
-
minIndex
public int minIndex()
-
maxIndex
public int maxIndex()
-
isSorted
public boolean isSorted()
Returns true if this index is sorted (in increasing order)- Returns:
-
isDistinctSorted
public boolean isDistinctSorted()
Returns true if this index is distinct and sorted (in strictly increasing order)- Returns:
-
sort
public void sort()
Sorts the index in place. May not be supported by some AIndex implementations e.g. if the index is immutable.
-
isDistinct
public boolean isDistinct()
Returns true if this Index contains only distinct integer indices- Returns:
-
isPermutation
public boolean isPermutation()
Returns true if this index represents a permutation of positions 0..length-1- Returns:
-
contains
public boolean contains(int index)
Returns true if the index contains a specific value. Performs a full scan of the index (need not be in sorted order)- Parameters:
index-- Returns:
-
containsSorted
public boolean containsSorted(int index)
Returns true if the index contains a specific value. Assumes the index is in sorted order.- Parameters:
index-- Returns:
-
contains
public boolean contains(Index inds)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
equals
public boolean equals(AIndex o)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clone
public AIndex clone()
- Overrides:
clonein classjava.lang.Object
-
compareTo
public int compareTo(AIndex a)
- Specified by:
compareToin interfacejava.lang.Comparable<AIndex>
-
iterator
public IndexIterator iterator()
Gets an iterator over all elements of this index- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.Integer>
-
compose
public Index compose(AIndex a)
Composes this index with a second index, returning a new index. New index satisfies index.get(i) == a.get(this.get(i));- Parameters:
a-- Returns:
-
indexPosition
public abstract int indexPosition(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.- Parameters:
x-- Returns:
-
seekPosition
public int seekPosition(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.- Parameters:
i-- Returns:
- The target position in the index, which will satisfy 0 <= position <= this.length()
-
exactClone
public abstract AIndex exactClone()
-
last
public abstract int last()
Gets the last index value in this index. Throws an exception if the index is empty- Returns:
-
-
DMelt 3.0 © DataMelt by jWork.ORG