public class RangeSet extends AbstractSet<Integer> implements Cloneable, Serializable
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.
Constructor and Description |
---|
RangeSet(int stop)
Constructs a range set for a sequence of numbers, starting at
0 with
the value to stop. |
RangeSet(int start,
int stop)
Constructs a range set for the specified range of integers with a step of
1 . |
RangeSet(int start,
int stop,
int step)
Constructs a range set for the specified range of integers and increment.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Object o)
Returns
true if this set contains the specified element. |
boolean |
isEmpty()
Returns
true if this set contains no elements. |
Iterator<Integer> |
iterator()
Returns an iterator over the elements in this set.
|
int |
size()
Returns the number of elements in this set.
|
equals, hashCode, removeAll
add, addAll, clear, containsAll, remove, retainAll, toArray, toArray, toString
public RangeSet(int stop)
0
with
the value to stop. Equivalent to constructing the range set with:
RangeSet(0, stop, 1)
.stop
- the point at which to stop the range (exclusive).public RangeSet(int start, int stop)
1
.
Equivalent to constructing the range set with: RangeSet(start, stop, 1)
.start
- the start of the range (inclusive).stop
- the point at which to stop the range (exclusive).public RangeSet(int start, int stop, int step)
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.IllegalArgumentException
- if step
is 0
.public int size()
size
in interface Collection<Integer>
size
in interface Set<Integer>
size
in class AbstractCollection<Integer>
public boolean isEmpty()
true
if this set contains no elements.isEmpty
in interface Collection<Integer>
isEmpty
in interface Set<Integer>
isEmpty
in class AbstractCollection<Integer>
public boolean contains(Object o)
true
if this set contains the specified element.contains
in interface Collection<Integer>
contains
in interface Set<Integer>
contains
in class AbstractCollection<Integer>
o
- element whose presence in this set is to be tested.true
if this set contains the specified element.Copyright 2011-2015 ForgeRock AS.