Package jflex.chars
Class Interval
- java.lang.Object
-
- jflex.chars.Interval
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classInterval.IntervalIteratorIterator for enumerating the elements of this Interval
-
Constructor Summary
Constructors Constructor Description Interval(int start, int end)Constructs a new interval fromstarttoend, including both end points.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(int point)Returnstrueiffpointis contained in this interval.booleancontains(Interval other)Returntrueiff this interval completely contains the other one.static IntervalcopyOf(Interval interval)Creates a copy of the interval.booleanequals(Object o)Returnstrueifois an interval with the same borders.inthashCode()booleaninvariants()Checks the invariants of this object.Interval.IntervalIteratoriterator()static IntervalofCharacter(int c)Creates an interval of a single character.intsize()Computes the size of this interval.StringtoString()Returns a String representation of this interval.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
contains
public boolean contains(int point)
Returnstrueiffpointis contained in this interval.- Parameters:
point- the character codepoint to check- Returns:
- whether the code point is contained in the interval.
-
contains
public boolean contains(Interval other)
Returntrueiff this interval completely contains the other one.- Parameters:
other- the other interval- Returns:
- whether this interval completely contains the other one.
-
equals
public boolean equals(Object o)
Returnstrueifois an interval with the same borders.
-
toString
public String toString()
Returns a String representation of this interval.
-
ofCharacter
public static Interval ofCharacter(int c)
Creates an interval of a single character.- Parameters:
c- The unique codepoint contained in this interval.- Returns:
- A single-character interval.
-
copyOf
public static Interval copyOf(Interval interval)
Creates a copy of the interval.- Returns:
- the copy of the given interval.
-
size
public int size()
Computes the size of this interval.- Returns:
- how many characters this interval spans
-
invariants
public boolean invariants()
Checks the invariants of this object.- Returns:
- true when the invariants of this objects hold.
-
iterator
public Interval.IntervalIterator iterator()
-
-