net.sf.saxon.sort

Class IntRangeSet

Implemented Interfaces:
Serializable, IntSet

public class IntRangeSet
extends java.lang.Object
implements Serializable, IntSet

Set of int values. This implementation of IntSet uses a sorted array of integer ranges.
Author:
Michael Kay

Constructor Summary

IntRangeSet()
Create an empty set
IntRangeSet(IntRangeSet input)
Create one IntRangeSet as a copy of another

Method Summary

boolean
add(int value)
Add an integer to the set
void
addRange(int low, int high)
Add a range of integers to the set.
void
clear()
boolean
contains(int value)
boolean
containsAll(IntSet other)
Test if this set is a superset of another set
boolean
equals(Object other)
Test whether this set has exactly the same members as another set.
int[]
getEndPoints()
Get the end points of the ranges
int
getNumberOfRanges()
Get the number of ranges actually in use
int[]
getStartPoints()
Get the start points of the ranges
int
hashCode()
Construct a hash key that supports the equals() test
boolean
isEmpty()
IntIterator
iterator()
Get an iterator over the values
boolean
remove(int value)
int
size()
String
toString()

Constructor Details

IntRangeSet

public IntRangeSet()
Create an empty set

IntRangeSet

public IntRangeSet(IntRangeSet input)
Create one IntRangeSet as a copy of another
Parameters:
input - the IntRangeSet to be copied

Method Details

add

public boolean add(int value)
Add an integer to the set
Specified by:
add in interface IntSet
Parameters:
value - the integer to be added
Returns:
true if the integer was added, false if it was already present

addRange

public void addRange(int low,
                     int high)
Add a range of integers to the set. This is optimized for the case where these are all greater than any existing integer in the set.
Parameters:
low - the low end of the new range
high - the high end of the new range

clear

public void clear()
Specified by:
clear in interface IntSet

contains

public boolean contains(int value)
Specified by:
contains in interface IntSet

containsAll

public boolean containsAll(IntSet other)
Test if this set is a superset of another set
Specified by:
containsAll in interface IntSet

equals

public boolean equals(Object other)
Test whether this set has exactly the same members as another set. Note that IntRangeSet values are NOT comparable with other implementations of IntSet

getEndPoints

public int[] getEndPoints()
Get the end points of the ranges

getNumberOfRanges

public int getNumberOfRanges()
Get the number of ranges actually in use

getStartPoints

public int[] getStartPoints()
Get the start points of the ranges

hashCode

public int hashCode()
Construct a hash key that supports the equals() test

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface IntSet

iterator

public IntIterator iterator()
Get an iterator over the values
Specified by:
iterator in interface IntSet

remove

public boolean remove(int value)
Specified by:
remove in interface IntSet

size

public int size()
Specified by:
size in interface IntSet

toString

public String toString()