IntervalSet

This class implements the {@link IntSet} backed by a sorted array of non-overlapping intervals. It is particularly efficient for representing large collections of numbers, where the majority of elements appear as part of a sequential range of numbers that are all part of the set. For example, the set { 1, 2, 3, 4, 7, 8 } may be represented as { [1, 4], [7, 8] }.

<p> This class is able to represent sets containing any combination of values in the range {@link Integer#MIN_VALUE} to {@link Integer#MAX_VALUE} (inclusive).</p>

Constructors

this
this()
Undocumented in source.
this
this(Interval[] intervals)
Undocumented in source.
this
this(IntervalSet set)
Undocumented in source.
this
this(int[] els)
Undocumented in source.

Members

Functions

add
void add(int el)

Add a single element to the set. An isolated element is stored as a range el..el. @uml @override

add
void add(int a, int b)

Add interval; i.e., add all integers from a to b to set. If b&lt;a, do nothing. Keep list in sorted order (by left range value). If overlap, combine ranges. For example, If this is {1..5, 10..20}, adding 6..7 yields {1..5, 6..7, 10..20}. Adding 4..8 yields {1..8, 10..20}.

add
void add(Interval addition)

copy on write so we can cache a..a intervals and sets of that

addAll
IntervalSet addAll(IntSet set)
Undocumented in source. Be warned that the author may not have intended to support it.
and
IntervalSet and(IntSet other)
Undocumented in source. Be warned that the author may not have intended to support it.
clear
void clear()
Undocumented in source. Be warned that the author may not have intended to support it.
complement
IntervalSet complement(int minElement, int maxElement)
Undocumented in source. Be warned that the author may not have intended to support it.
complement
IntervalSet complement(IntSet vocabulary)

{@inheritDoc}

complement
IntervalSet complement(IntervalSet vocabulary)
Undocumented in source. Be warned that the author may not have intended to support it.
contains
bool contains(int el)
Undocumented in source. Be warned that the author may not have intended to support it.
elementName
string elementName(Vocabulary vocabulary, int a)
Undocumented in source. Be warned that the author may not have intended to support it.
get
int get(int i)

Get the ith element of ordered set. Used only by RandomPhrase so don't bother to implement if you're not doing that for a new ANTLR code gen target. @uml @safe @pure

getMaxElement
int getMaxElement()

Returns the maximum value contained in the set.

getMinElement
int getMinElement()

Returns the minimum value contained in the set.

getSingleElement
int getSingleElement()
Undocumented in source. Be warned that the author may not have intended to support it.
intervals
Interval[] intervals()

@uml @final

isNil
bool isNil()
Undocumented in source. Be warned that the author may not have intended to support it.
isReadonly
bool isReadonly()

@uml @safe @pure

opEquals
bool opEquals(Object obj)

@uml @override

or
IntervalSet or(IntSet a)
Undocumented in source. Be warned that the author may not have intended to support it.
remove
void remove(int el)
Undocumented in source. Be warned that the author may not have intended to support it.
setReadonly
void setReadonly(bool readonly)

@uml @safe @pure

size
int size()
Undocumented in source. Be warned that the author may not have intended to support it.
subtract
IntervalSet subtract(IntSet a)
Undocumented in source. Be warned that the author may not have intended to support it.
subtract
IntervalSet subtract(IntervalSet left, IntervalSet right)

Compute the set difference between two interval sets. The specific operation is {@code left - right}. If either of the input sets is {@code null}, it is treated as though it was an empty set.

toArray
int[] toArray()
Undocumented in source. Be warned that the author may not have intended to support it.
toIntegerList
IntegerList toIntegerList()
Undocumented in source. Be warned that the author may not have intended to support it.
toList
int[] toList()
Undocumented in source. Be warned that the author may not have intended to support it.
toSet
RedBlackTree!int toSet()
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString(bool elemAreChar)
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()

@uml @override

toString
string toString(Vocabulary vocabulary)
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

of
IntervalSet of(int a)

Create a set with a single element, el.

of
IntervalSet of(int a, int b)

Create a set with all ints within range a..b (inclusive)

or
IntervalSet or(IntervalSet[] sets)

combine all sets in the array returned the or'd value

Static variables

COMPLETE_CHAR_SET
IntervalSet COMPLETE_CHAR_SET;
Undocumented in source.
EMPTY_SET
IntervalSet EMPTY_SET;
Undocumented in source.

Meta