Package net.sf.saxon.sort
Class IntArraySet
- java.lang.Object
-
- net.sf.saxon.sort.IntArraySet
-
- All Implemented Interfaces:
java.io.Serializable
public class IntArraySet extends java.lang.Object implements java.io.Serializable
Set of int values. This class is modelled on the java.net.Set interface, but it does not implement this interface, because the set members are int's rather than Objects. It does implement the same interface as IntHashSet, although this is currently not defined as an explicit interface. This implementation of a set of integers is optimized to use very little storage and to provide fast comparison of two sets. The equals() method determines whether two sets contain the same integers. Not thread safe.- Author:
- Michael Kay
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IntArraySet()
Create an empty setIntArraySet(IntArraySet input)
Create one IntArraySet as a copy of anotherIntArraySet(IntHashSet input)
Create a set containing integers from the specified IntHashSet
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(int value)
Add an integer to the setvoid
clear()
boolean
contains(int value)
boolean
equals(java.lang.Object other)
Test whether this set has exactly the same members as another setint
getFirst()
Get the first value in the set.int[]
getValues()
int
hashCode()
Construct a hash key that supports the equals() testboolean
isEmpty()
IntIterator
iterator()
Get an iterator over the valuesstatic IntArraySet
make(int[] in, int size)
boolean
remove(int value)
int
size()
java.lang.String
toString()
IntArraySet
union(IntArraySet other)
Form a new set that is the union of this set with another set.
-
-
-
Constructor Detail
-
IntArraySet
public IntArraySet()
Create an empty set
-
IntArraySet
public IntArraySet(IntHashSet input)
Create a set containing integers from the specified IntHashSet
-
IntArraySet
public IntArraySet(IntArraySet input)
Create one IntArraySet as a copy of another
-
-
Method Detail
-
clear
public void clear()
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
getValues
public int[] getValues()
-
contains
public boolean contains(int value)
-
remove
public boolean remove(int value)
-
add
public boolean add(int value)
Add an integer to the set- Parameters:
value
- the integer to be added- Returns:
- true if the integer was added, false if it was already present
-
getFirst
public int getFirst()
Get the first value in the set.- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if the set is empty
-
iterator
public IntIterator iterator()
Get an iterator over the values
-
union
public IntArraySet union(IntArraySet other)
Form a new set that is the union of this set with another set.
-
make
public static IntArraySet make(int[] in, int size)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
Test whether this set has exactly the same members as another set- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Construct a hash key that supports the equals() test- Overrides:
hashCode
in classjava.lang.Object
-
-