Refactored for AB5
This commit is contained in:
@ -1,94 +1,108 @@
|
||||
// A list of massive objects implemented as a linked list.
|
||||
// The number of elements of the list is not limited.
|
||||
/**
|
||||
* A list of massive objects implemented as a linked list.
|
||||
* The number of elements of the list is not limited.
|
||||
*/
|
||||
public class MassiveLinkedList {
|
||||
|
||||
//TODO: declare variables.
|
||||
|
||||
// Initializes 'this' as an empty list.
|
||||
/**
|
||||
* Initializes 'this' as an empty list.
|
||||
*/
|
||||
public MassiveLinkedList() {
|
||||
|
||||
//TODO: define constructor.
|
||||
}
|
||||
|
||||
// Initializes 'this' as an independent copy of the specified list 'list'.
|
||||
// Calling methods of this list will not affect the specified list 'list'
|
||||
// and vice versa.
|
||||
// Precondition: list != null.
|
||||
/**
|
||||
* Initializes 'this' as an independent copy of the specified list 'list'.
|
||||
* Calling methods of this list will not affect the specified list 'list'
|
||||
* and vice versa.
|
||||
* Precondition: list != null.
|
||||
*/
|
||||
public MassiveLinkedList(BodyLinkedList list) {
|
||||
|
||||
//TODO: define constructor.
|
||||
}
|
||||
|
||||
// Inserts the specified element 'body' at the beginning of this list.
|
||||
/**
|
||||
* Inserts the specified element 'body' at the beginning of this list.
|
||||
*/
|
||||
public void addFirst(Massive body) {
|
||||
|
||||
//TODO: implement method.
|
||||
}
|
||||
|
||||
// Appends the specified element 'body' to the end of this list.
|
||||
/**
|
||||
* Appends the specified element 'body' to the end of this list.
|
||||
*/
|
||||
public void addLast(Massive body) {
|
||||
|
||||
//TODO: implement method.
|
||||
}
|
||||
|
||||
// Returns the last element in this list.
|
||||
// Returns 'null' if the list is empty.
|
||||
/**
|
||||
* Returns the last element in this list.
|
||||
* Returns 'null' if the list is empty.
|
||||
*/
|
||||
public Massive getLast() {
|
||||
|
||||
//TODO: implement method.
|
||||
return null;
|
||||
}
|
||||
|
||||
// Returns the first element in this list.
|
||||
// Returns 'null' if the list is empty.
|
||||
/**
|
||||
* Returns the first element in this list.
|
||||
* Returns 'null' if the list is empty.
|
||||
*/
|
||||
public Massive getFirst() {
|
||||
|
||||
//TODO: implement method.
|
||||
return null;
|
||||
}
|
||||
|
||||
// Retrieves and removes the first element in this list.
|
||||
// Returns 'null' if the list is empty.
|
||||
/**
|
||||
* Retrieves and removes the first element in this list.
|
||||
* Returns 'null' if the list is empty.
|
||||
*/
|
||||
public Massive pollFirst() {
|
||||
|
||||
//TODO: implement method.
|
||||
return null;
|
||||
}
|
||||
|
||||
// Retrieves and removes the last element in this list.
|
||||
// Returns 'null' if the list is empty.
|
||||
/**
|
||||
* Retrieves and removes the last element in this list.
|
||||
* Returns 'null' if the list is empty.
|
||||
*/
|
||||
public Massive pollLast() {
|
||||
|
||||
//TODO: implement method.
|
||||
return null;
|
||||
}
|
||||
|
||||
// Inserts the specified element at the specified position in this list.
|
||||
// Precondition: i >= 0 && i <= size().
|
||||
/**
|
||||
* Inserts the specified element at the specified position in this list.
|
||||
* Precondition: i >= 0 && i <= size().
|
||||
*/
|
||||
public void add(int i, Massive m) {
|
||||
|
||||
//TODO: implement method.
|
||||
}
|
||||
|
||||
// Returns the element at the specified position in this list.
|
||||
// Precondition: i >= 0 && i < size().
|
||||
/**
|
||||
* Returns the element at the specified position in this list.
|
||||
* Precondition: i >= 0 && i < size().
|
||||
*/
|
||||
public Massive get(int i) {
|
||||
|
||||
//TODO: implement method.
|
||||
return null;
|
||||
}
|
||||
|
||||
// Returns the index of the first occurrence of the specified element in this list, or -1 if
|
||||
// this list does not contain the element.
|
||||
/**
|
||||
* Returns the index of the first occurrence of the specified element in this list, or -1 if
|
||||
* this list does not contain the element.
|
||||
*/
|
||||
public int indexOf(Massive m) {
|
||||
|
||||
//TODO: implement method.
|
||||
return -2;
|
||||
}
|
||||
|
||||
// Returns the number of elements in this list.
|
||||
/**
|
||||
* Returns the number of elements in this list.
|
||||
*/
|
||||
public int size() {
|
||||
|
||||
//TODO: implement method.
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user