Class IntArray
- java.lang.Object
-
- org.apache.lucene.util.collections.IntArray
-
public class IntArray extends Object
A Class wrapper for a grow-able int[] which can be sorted and intersect with other IntArrays.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description IntArray()
Construct a default IntArray, size 0 and surly a sort should not occur.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToArray(int value)
Adds a value to the array.void
clear(boolean resize)
Clear the IntArray (set all elements to zero).boolean
equals(Object o)
Equals method.int
get(int i)
Get an element from a specific index.int
hashCode()
Calculates a hash-code for HashTablesvoid
intersect(IntArray other)
Intersects the data with a given IntArrayvoid
intersect(IntHashSet set)
Intersects the data with a givenIntHashSet
.void
set(int idx, int value)
int
size()
Return the size of the Array.void
sort()
Sorts the data.String
toString()
toString or not toString.
-
-
-
Method Detail
-
intersect
public void intersect(IntHashSet set)
Intersects the data with a givenIntHashSet
.- Parameters:
set
- A given ArrayHashSetInt which holds the data to be intersected against
-
intersect
public void intersect(IntArray other)
Intersects the data with a given IntArray- Parameters:
other
- A given IntArray which holds the data to be intersected agains
-
size
public int size()
Return the size of the Array. Not the allocated size, but the number of values actually set.- Returns:
- the (filled) size of the array
-
addToArray
public void addToArray(int value)
Adds a value to the array.- Parameters:
value
- value to be added
-
equals
public boolean equals(Object o)
Equals method. Checking the sizes, than the values from the last index to the first (Statistically for random should be the same but for our specific use would find differences faster).
-
sort
public void sort()
Sorts the data. If it is needed.
-
hashCode
public int hashCode()
Calculates a hash-code for HashTables
-
get
public int get(int i)
Get an element from a specific index.- Parameters:
i
- index of which element should be retrieved.
-
set
public void set(int idx, int value)
-
toString
public String toString()
toString or not toString. That is the question!
-
clear
public void clear(boolean resize)
Clear the IntArray (set all elements to zero).- Parameters:
resize
- - if resize is true, then clear actually allocates a new array of size 0, essentially 'clearing' the array and freeing memory.
-
-