Interface ISimpleList<T>
-
- Type Parameters:
T- The type of elements in this list.
- All Known Implementing Classes:
NullUnlimitedList,SimpleArrayList
public interface ISimpleList<T>Interface for a simple list abstraction.This interface is a subset of the
Listinterface. It is intended to be used in cases where the fullListinterface is not needed.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidadd(int index, T element)Adds an element to the list at the specified index.voidadd(T element)Adds an element to the end of the list.Tget(int index)Returns the element at the specified index.intindexOf(java.lang.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.booleanisEmpty()Returnstrueif the list contains no elements, false otherwise.voidremove(int index)Removes the element at the specified index.Tset(int index, T element)Replaces the element at the specified index with the specified element.intsize()Returns the number of elements in the list.
-
-
-
Method Detail
-
add
void add(T element)
Adds an element to the end of the list.- Parameters:
element- the element to add
-
add
void add(int index, T element)Adds an element to the list at the specified index.- Parameters:
index- the index at which to add the elementelement- the element to add
-
get
T get(int index)
Returns the element at the specified index.- Parameters:
index- the index of the element to return- Returns:
- the element at the specified index
-
set
T set(int index, T element)
Replaces the element at the specified index with the specified element.- Parameters:
index- the index of the element to replaceelement- the element to be stored at the specified index- Returns:
- the element previously at the specified index
-
indexOf
int indexOf(java.lang.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.- Parameters:
element- the element to search for- Returns:
- the index of the first occurrence of the specified element in the list, or -1 if the list does not contain the element
-
remove
void remove(int index)
Removes the element at the specified index.- Parameters:
index- the index of the element to be removed
-
size
int size()
Returns the number of elements in the list.- Returns:
- the number of elements in the list
-
isEmpty
boolean isEmpty()
Returnstrueif the list contains no elements, false otherwise.- Returns:
trueif the list contains no elements, false otherwise
-
-