Top Description Inners Fields Constructors Methods
kotlin.reflect.jvm.internal.impl.utils

public Class SmartList<E>

extends AbstractList<E>
implements RandomAccess
Class Inheritance
All Implemented Interfaces
java.util.RandomAccess
Annotations
@SuppressWarnings:unchecked
Imports
org.jetbrains.annotations.NotNull, java.lang.reflect.Array, java.util.*

A List which is optimised for the sizes of 0 and 1, in which cases it would not allocate array at all. This class was copied from com.intellij.util.SmartList.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class
private abstract static class

Field Summary

Modifier and TypeField and Description
private Object
private int
Inherited from java.util.AbstractList:
modCount

Constructor Summary

AccessConstructor and Description
public
public
SmartList(E element)

public
SmartList(@NotNull Collection<? extends E> elements)

public
SmartList(E... elements)

Method Summary

Modifier and TypeMethod and Description
public boolean
add(E
element to be appended to this list
e
)

Overrides java.util.AbstractList.add.

Implements java.util.List.add, java.util.Collection.add.

Appends the specified element to the end of this list (optional operation).
public void
add(int
index at which the specified element is to be inserted
index
,
E
element to be inserted
e
)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation).
public void
clear()

Overrides java.util.AbstractList.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Removes all of the elements from this list (optional operation).
public E
get(int
index of the element to return
index
)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Returns the element at the specified position in this list.
public int
public @NotNull Iterator<E>
iterator()

Overrides java.util.AbstractList.iterator.

Implements java.util.List.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this list in proper sequence.
public E
remove(int
the index of the element to be removed
index
)

Overrides java.util.AbstractList.remove.

Implements java.util.List.remove.

Removes the element at the specified position in this list (optional operation).
public E
set(int
index of the element to replace
index
,
E
element to be stored at the specified position
element
)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Returns the number of elements in this list.
public void
sort(Comparator<? super E>
the Comparator used to compare list elements. A null value indicates that the elements' natural ordering should be used
comparator
)

Overrides default java.util.List.sort.

Sorts this list according to the order induced by the specified Comparator.
public <T> T[]
toArray(T[]
the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
a
)

Overrides java.util.AbstractCollection.toArray.

Implements java.util.List.toArray, java.util.Collection.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.
public void
trimToSize()

Trims the capacity of this list to be the list's current size.

Inherited from java.util.AbstractList:
addAllequalshashCodeindexOflastIndexOflistIteratorlistIteratorremoveRangesubList

Field Detail

myElemback to summary
private Object myElem
mySizeback to summary
private int mySize

Constructor Detail

SmartListback to summary
public SmartList()
SmartListback to summary
public SmartList(E element)
SmartListback to summary
public SmartList(@NotNull Collection<? extends E> elements)
SmartListback to summary
public SmartList(E... elements)

Method Detail

addback to summary
public boolean add(E e)

Overrides java.util.AbstractList.add.

Implements java.util.List.add, java.util.Collection.add.

Doc from java.util.AbstractList.add.

Appends the specified element to the end of this list (optional operation).

Lists that support this operation may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. List classes should clearly specify in their documentation any restrictions on what elements may be added.

Parameters
e:E

element to be appended to this list

Returns:boolean

true (as specified by Collection#add)

Annotations
@Override
addback to summary
public void add(int index, E e)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Doc from java.util.AbstractList.add.

Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters
index:int

Doc from java.util.List.add.

index at which the specified element is to be inserted

e:E

Doc from java.util.List.add.

element to be inserted

Annotations
@Override
clearback to summary
public void clear()

Overrides java.util.AbstractList.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Doc from java.util.AbstractList.clear.

Removes all of the elements from this list (optional operation). The list will be empty after this call returns.

Annotations
@Override
getback to summary
public E get(int index)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Doc from java.util.AbstractList.get.

Returns the element at the specified position in this list.

Parameters
index:int

Doc from java.util.List.get.

index of the element to return

Returns:E

Doc from java.util.List.get.

the element at the specified position in this list

Annotations
@Override
getModificationCountback to summary
public int getModificationCount()
iteratorback to summary
public @NotNull Iterator<E> iterator()

Overrides java.util.AbstractList.iterator.

Implements java.util.List.iterator, java.util.Collection.iterator.

Doc from java.util.AbstractList.iterator.

Returns an iterator over the elements in this list in proper sequence.

Returns:@NotNull Iterator<E>

an iterator over the elements in this list in proper sequence

Annotations
@NotNull
@Override
removeback to summary
public E remove(int index)

Overrides java.util.AbstractList.remove.

Implements java.util.List.remove.

Doc from java.util.AbstractList.remove.

Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Parameters
index:int

Doc from java.util.List.remove.

the index of the element to be removed

Returns:E

Doc from java.util.List.remove.

the element previously at the specified position

Annotations
@Override
setback to summary
public E set(int index, E element)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Doc from java.util.AbstractList.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

Parameters
index:int

Doc from java.util.List.set.

index of the element to replace

element:E

Doc from java.util.List.set.

element to be stored at the specified position

Returns:E

Doc from java.util.List.set.

the element previously at the specified position

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Doc from java.util.List.size.

Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this list

Annotations
@Override
sortback to summary
public void sort(Comparator<? super E> comparator)

Overrides default java.util.List.sort.

Doc from java.util.List.sort.

Sorts this list according to the order induced by the specified Comparator. The sort is stable: this method must not reorder equal elements.

All elements in this list must be mutually comparable using the specified comparator (that is, c.compare(e1, e2) must not throw a ClassCastException for any elements e1 and e2 in the list).

If the specified comparator is null then all elements in this list must implement the Comparable interface and the elements' natural ordering should be used.

This list must be modifiable, but need not be resizable.

Parameters
comparator:Comparator<? super E>

the Comparator used to compare list elements. A null value indicates that the elements' natural ordering should be used

toArrayback to summary
public <T> T[] toArray(T[] a)

Overrides java.util.AbstractCollection.toArray.

Implements java.util.List.toArray, java.util.Collection.toArray.

Doc from java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list.

If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the list is set to null. (This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.)

Like the toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

Suppose x is a list known to contain only strings. The following code can be used to dump the list into a newly allocated array of String:

String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to toArray().
Parameters
<T>

Doc from java.util.Collection.toArray. the component type of the array to contain the collection

a:T[]

the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.

Returns:T[]

an array containing the elements of this list

Annotations
@NotNull
@Override
trimToSizeback to summary
public void trimToSize()

Trims the capacity of this list to be the list's current size. An application can use this operation to minimize the storage of a list instance.

kotlin.reflect.jvm.internal.impl.utils back to summary

private Class SmartList.EmptyIterator<T>

extends Object
implements Iterator<T>
Class Inheritance
  • java.lang.Object
  • kotlin.reflect.jvm.internal.impl.utils.SmartList.EmptyIterator
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private static final SmartList.EmptyIterator<T>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <T> SmartList.EmptyIterator<T>
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public T
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
private static final SmartList.EmptyIterator<T> INSTANCE

Constructor Detail

EmptyIteratorback to summary
private EmptyIterator()

Method Detail

getInstanceback to summary
public static <T> SmartList.EmptyIterator<T> getInstance()
hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public T next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:T

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override
kotlin.reflect.jvm.internal.impl.utils back to summary

private Class SmartList.SingletonIterator

extends SmartList.SingletonIteratorBase<E>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected E
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from kotlin.reflect.jvm.internal.impl.utils.SmartList.SingletonIteratorBase:
hasNextnext

Field Detail

myInitialModCountback to summary
private final int myInitialModCount

Constructor Detail

SingletonIteratorback to summary
public SingletonIterator()

Method Detail

checkCoModificationback to summary
protected void checkCoModification()

Implements abstract kotlin.reflect.jvm.internal.impl.utils.SmartList.SingletonIteratorBase.checkCoModification.

Annotations
@Override
getElementback to summary
protected E getElement()

Implements abstract kotlin.reflect.jvm.internal.impl.utils.SmartList.SingletonIteratorBase.getElement.

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override
kotlin.reflect.jvm.internal.impl.utils back to summary

private abstract Class SmartList.SingletonIteratorBase<T>

extends Object
implements Iterator<T>
Class Inheritance
  • java.lang.Object
  • kotlin.reflect.jvm.internal.impl.utils.SmartList.SingletonIteratorBase
All Implemented Interfaces
java.util.Iterator
Known Direct Subclasses
kotlin.reflect.jvm.internal.impl.utils.SmartList.SingletonIterator

Field Summary

Modifier and TypeField and Description
private boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected abstract void
protected abstract T
public final boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public final T
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

myVisitedback to summary
private boolean myVisited

Constructor Detail

SingletonIteratorBaseback to summary
private SingletonIteratorBase()

Method Detail

checkCoModificationback to summary
protected abstract void checkCoModification()
getElementback to summary
protected abstract T getElement()
hasNextback to summary
public final boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public final T next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:T

the next element in the iteration

Annotations
@Override