Top Description Methods
org.antlr.v4.runtime.misc

public Interface IntSet

Known Direct Implementers
org.antlr.v4.runtime.misc.IntervalSet
Imports
org.antlr.v4.runtime.Token, java.util.List

A generic set of integers.
See Also
IntervalSet

Method Summary

Modifier and TypeMethod and Description
public void
add(int
the value to add
el
)

Adds the specified value to the current set.

public IntSet

Returns:

this (to support chained calls)
addAll
(IntSet
The set to add to the current set. A null argument is treated as though it were an empty set.
set
)

Modify the current IntSet object to contain all elements that are present in itself, the specified set, or both.

public IntSet

Returns:

A new IntSet instance containing the intersection of the current set and a. The value null may be returned in place of an empty result set.
and
(IntSet
The set to intersect with the current set. A null argument is treated as though it were an empty set.
a
)

Return a new IntSet object containing all elements that are present in both the current set and the specified set a.

public IntSet

Returns:

A new IntSet instance containing the elements present in elements but not present in the current set. The value null may be returned in place of an empty result set.
complement
(IntSet
The set to compare with the current set. A null argument is treated as though it were an empty set.
elements
)

Return a new IntSet object containing all elements that are present in elements but not present in the current set.

public boolean

Returns:

true if the set contains el; otherwise false.
contains
(int
The element to check for.
el
)

Returns true if the set contains the specified element.

public boolean
public int

Returns:

the single value contained in the set, if size is 1; otherwise, returns Token#INVALID_TYPE.
getSingleElement
()

Returns the single value contained in the set, if size is 1; otherwise, returns Token#INVALID_TYPE.

public boolean

Returns:

true if the current set contains no elements; otherwise, false.
isNil
()

Returns true if this set contains no elements.

public IntSet

Returns:

A new IntSet instance containing the union of the current set and a. The value null may be returned in place of an empty result set.
or
(IntSet
The set to union with the current set. A null argument is treated as though it were an empty set.
a
)

Return a new IntSet object containing all elements that are present in the current set, the specified set a, or both.

public void
remove(int
the value to remove
el
)

Removes the specified value from the current set.

public int

Returns:

the total number of elements represented by the current set, regardless of the manner in which the elements are stored.
size
()

Return the total number of elements represented by the current set.

public IntSet

Returns:

A new IntSet instance containing the elements present in elements but not present in the current set. The value null may be returned in place of an empty result set.
subtract
(IntSet
The set to compare with the current set. A null argument is treated as though it were an empty set.
a
)

Return a new IntSet object containing all elements that are present in the current set but not present in the input set a.

public List<Integer>

Returns:

A list containing all element present in the current set, sorted in ascending numerical order.
toList
()

Return a list containing the elements represented by the current set.

public String

Method Detail

addback to summary
public void add(int el)

Adds the specified value to the current set.

Parameters
el:int

the value to add

Exceptions
IllegalStateException:
if the current set is read-only
addAllback to summary
public IntSet addAll(IntSet set)

Modify the current IntSet object to contain all elements that are present in itself, the specified set, or both.

Parameters
set:IntSet

The set to add to the current set. A null argument is treated as though it were an empty set.

Returns:IntSet

this (to support chained calls)

Annotations
@NotNull
Exceptions
IllegalStateException:
if the current set is read-only
andback to summary
public IntSet and(IntSet a)

Return a new IntSet object containing all elements that are present in both the current set and the specified set a.

Parameters
a:IntSet

The set to intersect with the current set. A null argument is treated as though it were an empty set.

Returns:IntSet

A new IntSet instance containing the intersection of the current set and a. The value null may be returned in place of an empty result set.

Annotations
@Nullable
complementback to summary
public IntSet complement(IntSet elements)

Return a new IntSet object containing all elements that are present in elements but not present in the current set. The following expressions are equivalent for input non-null IntSet instances x and y.

  • x.complement(y)
  • y.subtract(x)
Parameters
elements:IntSet

The set to compare with the current set. A null argument is treated as though it were an empty set.

Returns:IntSet

A new IntSet instance containing the elements present in elements but not present in the current set. The value null may be returned in place of an empty result set.

Annotations
@Nullable
containsback to summary
public boolean contains(int el)

Returns true if the set contains the specified element.

Parameters
el:int

The element to check for.

Returns:boolean

true if the set contains el; otherwise false.

equalsback to summary
public boolean equals(Object obj)
Annotations
@Override
getSingleElementback to summary
public int getSingleElement()

Returns the single value contained in the set, if size is 1; otherwise, returns Token#INVALID_TYPE.

Returns:int

the single value contained in the set, if size is 1; otherwise, returns Token#INVALID_TYPE.

isNilback to summary
public boolean isNil()

Returns true if this set contains no elements.

Returns:boolean

true if the current set contains no elements; otherwise, false.

orback to summary
public IntSet or(IntSet a)

Return a new IntSet object containing all elements that are present in the current set, the specified set a, or both.

This method is similar to addAll(IntSet), but returns a new IntSet instance instead of modifying the current set.

Parameters
a:IntSet

The set to union with the current set. A null argument is treated as though it were an empty set.

Returns:IntSet

A new IntSet instance containing the union of the current set and a. The value null may be returned in place of an empty result set.

Annotations
@Nullable
removeback to summary
public void remove(int el)

Removes the specified value from the current set. If the current set does not contain the element, no changes are made.

Parameters
el:int

the value to remove

Exceptions
IllegalStateException:
if the current set is read-only
sizeback to summary
public int size()

Return the total number of elements represented by the current set.

Returns:int

the total number of elements represented by the current set, regardless of the manner in which the elements are stored.

subtractback to summary
public IntSet subtract(IntSet a)

Return a new IntSet object containing all elements that are present in the current set but not present in the input set a. The following expressions are equivalent for input non-null IntSet instances x and y.

  • y.subtract(x)
  • x.complement(y)
Parameters
a:IntSet

The set to compare with the current set. A null argument is treated as though it were an empty set.

Returns:IntSet

A new IntSet instance containing the elements present in elements but not present in the current set. The value null may be returned in place of an empty result set.

Annotations
@Nullable
toListback to summary
public List<Integer> toList()

Return a list containing the elements represented by the current set. The list is returned in ascending numerical order.

Returns:List<Integer>

A list containing all element present in the current set, sorted in ascending numerical order.

Annotations
@NotNull
toStringback to summary
public String toString()
Annotations
@Override