|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection<Integer>
it.unimi.dsi.fastutil.ints.AbstractIntCollection
it.unimi.dsi.fastutil.ints.AbstractIntSet
it.unimi.dsi.fastutil.ints.AbstractIntSortedSet
it.unimi.dsi.util.Interval
public final class Interval
An interval of integers. An interval is defined
by two integers, called its left and right
extremes, and contains all integers x such that
left ≤ x ≤ right.
This class has no constructor: use the static factory methods
valueOf(int, int) and valueOf(int), instead.
Instances of this class are immutable, and moreover implement
the IntSortedSet interface. The
equality method allows to check equality with
both sorted and non-sorted sets of integers.
To reduce garbage collection, intervals made of one non-negative small points are precomputed and returned upon request.
| Field Summary | |
|---|---|
int |
left
The left extreme of the interval. |
int |
right
The right extreme of the interval. |
| Constructor Summary | |
|---|---|
protected |
Interval(int left,
int right)
Builds an interval with given extremes. |
| Method Summary | |
|---|---|
IntComparator |
comparator()
|
int |
compareTo(int x)
Compares this interval to an integer. |
int |
compareTo(int x,
int radius)
Compares this interval to an integer with a specified radius. |
int |
compareTo(int x,
int leftRadius,
int rightRadius)
Compares this interval to an integer with specified left and right radii. |
boolean |
contains(int x)
Checks whether this interval contains the specified integer. |
boolean |
contains(Interval interval)
Checks whether this interval contains the specified interval. |
boolean |
contains(int x,
int radius)
Checks whether this interval would contain the specified integer if enlarged in both directions by the specified radius. |
boolean |
contains(int x,
int leftRadius,
int rightRadius)
Checks whether this interval would contain the specified integer if enlarged in each direction with the respective radius. |
boolean |
equals(Object o)
Checks whether this interval is equal to another set of integers. |
int |
firstInt()
|
int |
hashCode()
|
IntSortedSet |
headSet(int to)
|
IntBidirectionalIterator |
iterator()
Returns an iterator over the integers in this interval. |
IntBidirectionalIterator |
iterator(int from)
Returns an iterator over the integers in this interval larger than or equal to a given integer. |
int |
lastInt()
|
int |
length()
Returns the interval length, that is, the number of integers contained in the interval. |
int |
size()
An alias for length(). |
IntSortedSet |
subSet(int from,
int to)
|
IntSortedSet |
tailSet(int from)
|
String |
toString()
|
static Interval |
valueOf(int point)
Returns a one-point interval. |
static Interval |
valueOf(int left,
int right)
Returns an interval with given extremes. |
| Methods inherited from class it.unimi.dsi.fastutil.ints.AbstractIntSortedSet |
|---|
first, headSet, intIterator, last, subSet, tailSet |
| Methods inherited from class it.unimi.dsi.fastutil.ints.AbstractIntSet |
|---|
rem, remove, remove |
| Methods inherited from class it.unimi.dsi.fastutil.ints.AbstractIntCollection |
|---|
add, add, addAll, addAll, contains, containsAll, containsAll, isEmpty, rem, removeAll, removeAll, retainAll, retainAll, toArray, toArray, toArray, toIntArray, toIntArray |
| Methods inherited from class java.util.AbstractCollection |
|---|
clear |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface it.unimi.dsi.fastutil.ints.IntSortedSet |
|---|
headSet, intIterator, subSet, tailSet |
| Methods inherited from interface it.unimi.dsi.fastutil.ints.IntSet |
|---|
remove |
| Methods inherited from interface it.unimi.dsi.fastutil.ints.IntCollection |
|---|
add, addAll, containsAll, rem, removeAll, retainAll, toArray, toArray, toIntArray, toIntArray |
| Methods inherited from interface java.util.SortedSet |
|---|
first, last |
| Methods inherited from interface java.util.Set |
|---|
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
| Field Detail |
|---|
public final int left
public final int right
| Constructor Detail |
|---|
protected Interval(int left,
int right)
You cannot generate an empty interval with this constructor. Use Intervals.EMPTY_INTERVAL instead.
left - the left extreme.right - the right extreme (which must be greater than
or equal to the left extreme).| Method Detail |
|---|
public static Interval valueOf(int left,
int right)
You cannot obtain an empty interval with this factory method. Use Intervals.EMPTY_INTERVAL instead.
left - the left extreme.right - the right extreme (which must be greater than
or equal to the left extreme).
public static Interval valueOf(int point)
You cannot obtain an empty interval with this factory method. Use Intervals.EMPTY_INTERVAL instead.
point - a point.
public int length()
public int size()
length().
size in interface Collection<Integer>size in interface Set<Integer>size in class AbstractCollection<Integer>public IntBidirectionalIterator iterator()
iterator in interface IntCollectioniterator in interface IntIterableiterator in interface IntSetiterator in interface IntSortedSetiterator in interface Iterable<Integer>iterator in interface Collection<Integer>iterator in interface Set<Integer>iterator in class AbstractIntSortedSetpublic IntBidirectionalIterator iterator(int from)
iterator in interface IntSortedSetfrom - the starting integer.
public boolean contains(int x)
contains in interface IntCollectioncontains in class AbstractIntCollectionx - an integer.
x, that is,
whether left ≤ x ≤ right.public boolean contains(Interval interval)
interval - an interval.
interval.
public boolean contains(int x,
int radius)
x - an integer.radius - the radius.
radius would contain x,
e.g., whether left−radius ≤ x ≤ right+radius.
public boolean contains(int x,
int leftRadius,
int rightRadius)
x - an integer.leftRadius - the left radius.rightRadius - the right radius.
leftRadius
and to the right by rightRadius would contain x,
e.g., whether left−leftRadius ≤ x ≤ right+rightRadius.public int compareTo(int x)
x - an integer.
x is positioned
at the left, belongs, or is positioned to the right of this interval, e.g.,
as x < left,
left ≤ x ≤ right or
right < x.
public int compareTo(int x,
int radius)
x - an integer.radius - the radius.
x is positioned
at the left, belongs, or is positioned to the right of this interval enlarged by radius, that is,
as x < left−radius,
left−radius ≤ x ≤ right+radius or
right+radius < x.
public int compareTo(int x,
int leftRadius,
int rightRadius)
x - an integer.leftRadius - the left radius.rightRadius - the right radius.
x is positioned
at the left, belongs, or is positioned to the right of this interval enlarged by leftRadius
on the left and rightRadius in the right, that is,
as x < left−leftRadius,
left−leftRadius ≤ x ≤ right+rightRadius or
right+rightRadius < x.public IntComparator comparator()
comparator in interface IntSortedSetcomparator in interface SortedSet<Integer>public IntSortedSet headSet(int to)
headSet in interface IntSortedSetpublic IntSortedSet tailSet(int from)
tailSet in interface IntSortedSet
public IntSortedSet subSet(int from,
int to)
subSet in interface IntSortedSetpublic int firstInt()
firstInt in interface IntSortedSetpublic int lastInt()
lastInt in interface IntSortedSetpublic String toString()
toString in class AbstractIntCollectionpublic int hashCode()
hashCode in interface Collection<Integer>hashCode in interface Set<Integer>hashCode in class AbstractIntSetpublic boolean equals(Object o)
equals in interface Collection<Integer>equals in interface Set<Integer>equals in class AbstractIntSeto - an object.
o is an ordered set of integer containing
the same element of this interval in the same order, or if o
is a set of integers containing the same elements of this interval.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||