Package org.antlr.v4.runtime.misc
Class IntegerList
- java.lang.Object
-
- org.antlr.v4.runtime.misc.IntegerList
-
- Direct Known Subclasses:
IntegerStack
public class IntegerList extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private int[]
_data
private int
_size
private static int[]
EMPTY_DATA
private static int
INITIAL_SIZE
private static int
MAX_ARRAY_SIZE
-
Constructor Summary
Constructors Constructor Description IntegerList()
IntegerList(int capacity)
IntegerList(java.util.Collection<java.lang.Integer> list)
IntegerList(IntegerList list)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int value)
void
addAll(int[] array)
void
addAll(java.util.Collection<java.lang.Integer> list)
void
addAll(IntegerList list)
int
binarySearch(int key)
int
binarySearch(int fromIndex, int toIndex, int key)
private int
charArraySize()
void
clear()
boolean
contains(int value)
private void
ensureCapacity(int capacity)
boolean
equals(java.lang.Object o)
Compares the specified object with this list for equality.int
get(int index)
int
hashCode()
Returns the hash code value for this list.boolean
isEmpty()
int
removeAt(int index)
void
removeRange(int fromIndex, int toIndex)
int
set(int index, int value)
int
size()
void
sort()
int[]
toArray()
char[]
toCharArray()
Convert the list to a UTF-16 encoded char array.java.lang.String
toString()
Returns a string representation of this list.void
trimToSize()
-
-
-
Field Detail
-
EMPTY_DATA
private static int[] EMPTY_DATA
-
INITIAL_SIZE
private static final int INITIAL_SIZE
- See Also:
- Constant Field Values
-
MAX_ARRAY_SIZE
private static final int MAX_ARRAY_SIZE
- See Also:
- Constant Field Values
-
_data
private int[] _data
-
_size
private int _size
-
-
Constructor Detail
-
IntegerList
public IntegerList()
-
IntegerList
public IntegerList(int capacity)
-
IntegerList
public IntegerList(IntegerList list)
-
IntegerList
public IntegerList(java.util.Collection<java.lang.Integer> list)
-
-
Method Detail
-
add
public final void add(int value)
-
addAll
public final void addAll(int[] array)
-
addAll
public final void addAll(IntegerList list)
-
addAll
public final void addAll(java.util.Collection<java.lang.Integer> list)
-
get
public final int get(int index)
-
contains
public final boolean contains(int value)
-
set
public final int set(int index, int value)
-
removeAt
public final int removeAt(int index)
-
removeRange
public final void removeRange(int fromIndex, int toIndex)
-
isEmpty
public final boolean isEmpty()
-
size
public final int size()
-
trimToSize
public final void trimToSize()
-
clear
public final void clear()
-
toArray
public final int[] toArray()
-
sort
public final void sort()
-
equals
public boolean equals(java.lang.Object o)
Compares the specified object with this list for equality. Returnstrue
if and only if the specified object is also anIntegerList
, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. In other words, two lists are defined to be equal if they contain the same elements in the same order.This implementation first checks if the specified object is this list. If so, it returns
true
; if not, it checks if the specified object is anIntegerList
. If not, it returnsfalse
; if so, it checks the size of both lists. If the lists are not the same size, it returnsfalse
; otherwise it iterates over both lists, comparing corresponding pairs of elements. If any comparison returnsfalse
, this method returnsfalse
.- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- the object to be compared for equality with this list- Returns:
true
if the specified object is equal to this list
-
hashCode
public int hashCode()
Returns the hash code value for this list.This implementation uses exactly the code that is used to define the list hash function in the documentation for the
List.hashCode()
method.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hash code value for this list
-
toString
public java.lang.String toString()
Returns a string representation of this list.- Overrides:
toString
in classjava.lang.Object
-
binarySearch
public final int binarySearch(int key)
-
binarySearch
public final int binarySearch(int fromIndex, int toIndex, int key)
-
ensureCapacity
private void ensureCapacity(int capacity)
-
toCharArray
public final char[] toCharArray()
Convert the list to a UTF-16 encoded char array. If all values are less than the 0xFFFF 16-bit code point limit then this is just a char array of 16-bit char as usual. For values in the supplementary range, encode them as two UTF-16 code units.
-
charArraySize
private int charArraySize()
-
-