T - elements of the listpublic final class NullUnlimitedList<T> extends Object implements ISimpleList<T>
ArrayList and should have the same complexity (because keys are unique
integers, so collisions are impossible).| Constructor and Description |
|---|
NullUnlimitedList()
Creates a new instance of
NullUnlimitedList. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
T element)
Adds an element to the list at the specified index.
|
void |
add(T element)
Adds an element to the end of the list.
|
T |
get(int index)
Returns the element at the specified index.
|
int |
indexOf(Object element)
Returns the index of the first occurrence of the specified element in the list,
or -1 if the list does not contain the element.
|
boolean |
isEmpty()
Returns
true if the list contains no elements, false otherwise. |
void |
remove(int index)
In worth scenario O(n^2) but it is mostly impossible because keys shouldn't have
collisions at all (they are integers).
|
T |
set(int index,
T element)
Replaces the element at the specified index with the specified element.
|
int |
size()
Returns the number of elements in the list.
|
public NullUnlimitedList()
NullUnlimitedList.public void add(T element)
add in interface ISimpleList<T>element - the element to addpublic void add(int index,
T element)
add in interface ISimpleList<T>index - the index at which to add the elementelement - the element to addpublic T get(int index)
get in interface ISimpleList<T>index - the index of the element to returnpublic T set(int index, T element)
set in interface ISimpleList<T>index - the index of the element to replaceelement - the element to be stored at the specified indexpublic int indexOf(Object element)
indexOf in interface ISimpleList<T>element - the element to search forpublic void remove(int index)
remove in interface ISimpleList<T>index - the index of the element to be removedpublic int size()
ISimpleListsize in interface ISimpleList<T>public boolean isEmpty()
ISimpleListtrue if the list contains no elements, false otherwise.isEmpty in interface ISimpleList<T>Copyright © 1998–2025 Apryse Group NV. All rights reserved.