public class IntList
extends java.lang.Object
Constructor and Description |
---|
IntList()
Creates a new empty list.
|
Modifier and Type | Method and Description |
---|---|
int |
dataAt(int location)
Accesses the element at a given location.
|
int |
deleteFrom(int location)
Deletes the element at a given location.
|
int |
deleteFront()
Deletes the element at the front of the list.
|
void |
insertAt(int pos,
int y)
Inserts a new element.
|
void |
insertBack(int y)
Inserts a new element at the back of the list.
|
boolean |
isEmpty()
Checks whether the list is empty.
|
int |
locate(int key)
Checks whether a given element is in the list and, if it is, returns the
position (index) of its first occurence.
|
void |
print()
Prints the elements of the list
|
int |
size()
The size of the list.
|
void |
update(int pos,
int newValue)
Updates the value of the element at a given position.
|
public int dataAt(int location)
location
- The location to be accessed. It must hold that 0<= location <= size()-1.public int deleteFrom(int location)
location
- The location of the element to be deleted. It must hold that 0<= location <= size()-1.public int deleteFront()
public void insertAt(int pos, int y)
pos
- The location of the new element after insertion. It must hold that 0<= pos <= size().y
- The new elementpublic void insertBack(int y)
y
- The elements to be inserted.public boolean isEmpty()
public int locate(int key)
key
- The element to search for.public void print()
public int size()
public void update(int pos, int newValue)
pos
- The location of the update. It must hold that 0 <= pos <= size()-1.newValue
- The new value