Class Interval
java.lang.Object
jflex.chars.Interval
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassIterator for enumerating the elements of this Interval -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInterval(int start, int end) Constructs a new interval fromstarttoend, including both end points. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(int point) Returnstrueiffpointis contained in this interval.booleanReturntrueiff this interval completely contains the other one.static IntervalCreates a copy of the interval.booleanReturnstrueifois an interval with the same borders.inthashCode()booleanChecks the invariants of this object.private static booleanisPrintable(int c) Returns whether a character is printable.iterator()static IntervalofCharacter(int c) Creates an interval of a single character.intsize()Computes the size of this interval.toString()Returns a String representation of this interval.Methods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
start
public int startStart of the interval. -
end
public int endEnd of the interval.
-
-
Constructor Details
-
Interval
public Interval(int start, int end) Constructs a new interval fromstarttoend, including both end points.- Parameters:
start- first codepoint the interval containsend- last codepoint the interval contains
-
-
Method Details
-
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
Returntrueiff this interval completely contains the other one.- Parameters:
other- the other interval- Returns:
- whether this interval completely contains the other one.
-
equals
-
hashCode
-
isPrintable
private static boolean isPrintable(int c) Returns whether a character is printable.- Parameters:
c- the codepoint to check
-
toString
-
ofCharacter
Creates an interval of a single character.- Parameters:
c- The unique codepoint contained in this interval.- Returns:
- A single-character interval.
-
copyOf
-
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
-