Package jflex.chars

Class Interval

  • All Implemented Interfaces:
    java.lang.Iterable<java.lang.Integer>

    public final class Interval
    extends java.lang.Object
    implements java.lang.Iterable<java.lang.Integer>
    A mutable interval of characters with basic operations.
    Version:
    JFlex 1.9.1
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  Interval.IntervalIterator
      Iterator for enumerating the elements of this Interval
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int end
      End of the interval.
      int start
      Start of the interval.
    • Constructor Summary

      Constructors 
      Constructor Description
      Interval​(int start, int end)
      Constructs a new interval from start to end, including both end points.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(int point)
      Returns true iff point is contained in this interval.
      boolean contains​(Interval other)
      Return true iff this interval completely contains the other one.
      static Interval copyOf​(Interval interval)
      Creates a copy of the interval.
      boolean equals​(java.lang.Object o)
      Returns true if o is an interval with the same borders.
      int hashCode()  
      boolean invariants()
      Checks the invariants of this object.
      private static boolean isPrintable​(int c)
      Returns whether a character is printable.
      Interval.IntervalIterator iterator()  
      static Interval ofCharacter​(int c)
      Creates an interval of a single character.
      int size()
      Computes the size of this interval.
      java.lang.String toString()
      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
    • Field Detail

      • start

        public int start
        Start of the interval.
      • end

        public int end
        End of the interval.
    • Constructor Detail

      • Interval

        public Interval​(int start,
                        int end)
        Constructs a new interval from start to end, including both end points.
        Parameters:
        start - first codepoint the interval contains
        end - last codepoint the interval contains
    • Method Detail

      • contains

        public boolean contains​(int point)
        Returns true iff point is 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)
        Return true iff 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​(java.lang.Object o)
        Returns true if o is an interval with the same borders.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isPrintable

        private static boolean isPrintable​(int c)
        Returns whether a character is printable.
        Parameters:
        c - the codepoint to check
      • toString

        public java.lang.String toString()
        Returns a String representation of this interval.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string "[start-end]" or "[start]" (if there is only one character in the interval) where start and end are either a number (the character code) or something of the from 'a'.
      • 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()
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Integer>