Package org.forgerock.util
Class RangeSet
- java.lang.Object
 - 
- java.util.AbstractCollection<E>
 - 
- java.util.AbstractSet<Integer>
 - 
- org.forgerock.util.RangeSet
 
 
 
 
- 
- All Implemented Interfaces:
 Serializable,Cloneable,Iterable<Integer>,Collection<Integer>,Set<Integer>
public class RangeSet extends AbstractSet<Integer> implements Cloneable, Serializable
Exposes a range of integer values as a set. Avoids the allocation of storage for all values. Order of elements is guaranteed to be in the order from the specified start and stop values.If combination of start/stop/step values are not mathematically possible to represent as a set of values, it is represented by this implementation as an empty set.
- See Also:
 - Serialized Form
 
 
- 
- 
Constructor Summary
Constructors Constructor Description RangeSet(int stop)Constructs a range set for a sequence of numbers, starting at0with the value to stop.RangeSet(int start, int stop)Constructs a range set for the specified range of integers with a step of1.RangeSet(int start, int stop, int step)Constructs a range set for the specified range of integers and increment. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(Object o)Returnstrueif this set contains the specified element.booleanisEmpty()Returnstrueif this set contains no elements.Iterator<Integer>iterator()Returns an iterator over the elements in this set.intsize()Returns the number of elements in this set.- 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll 
- 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, containsAll, remove, retainAll, toArray, toArray, toString 
- 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait 
- 
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray 
- 
Methods inherited from interface java.util.Set
add, addAll, clear, containsAll, remove, retainAll, spliterator, toArray, toArray 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
RangeSet
public RangeSet(int stop)
Constructs a range set for a sequence of numbers, starting at0with the value to stop. Equivalent to constructing the range set with:RangeSet(0, stop, 1).- Parameters:
 stop- the point at which to stop the range (exclusive).
 
- 
RangeSet
public RangeSet(int start, int stop)Constructs a range set for the specified range of integers with a step of1. Equivalent to constructing the range set with:RangeSet(start, stop, 1).- Parameters:
 start- the start of the range (inclusive).stop- the point at which to stop the range (exclusive).
 
- 
RangeSet
public RangeSet(int start, int stop, int step)Constructs a range set for the specified range of integers and increment.- Parameters:
 start- the start of the range, inclusive.stop- the point at which to stop the range (exclusive).step- the step to increment for each value in the range.- Throws:
 IllegalArgumentException- ifstepis0.
 
 - 
 
- 
Method Detail
- 
size
public int size()
Returns the number of elements in this set.- Specified by:
 sizein interfaceCollection<Integer>- Specified by:
 sizein interfaceSet<Integer>- Specified by:
 sizein classAbstractCollection<Integer>
 
- 
isEmpty
public boolean isEmpty()
Returnstrueif this set contains no elements.- Specified by:
 isEmptyin interfaceCollection<Integer>- Specified by:
 isEmptyin interfaceSet<Integer>- Overrides:
 isEmptyin classAbstractCollection<Integer>
 
- 
contains
public boolean contains(Object o)
Returnstrueif this set contains the specified element.- Specified by:
 containsin interfaceCollection<Integer>- Specified by:
 containsin interfaceSet<Integer>- Overrides:
 containsin classAbstractCollection<Integer>- Parameters:
 o- element whose presence in this set is to be tested.- Returns:
 trueif this set contains the specified element.
 
 - 
 
 -