N | - | Number of data elements |
O | - | Number of operations |
N | O |
---|---|
1 | 3 |
1,000 | 3 |
1,000,000,000,0000 | 3 |
N | O |
---|---|
100 | 100 |
200 | 200 |
300 | 300 |
size() { return this._size; }
size() { return this._size; }
//Get first Let elem = get and hold element to remove removed element e.g. "this.get(0)" //Shift Shift all elements (starting at index position 1) to left //Set last to null (clear unused slot/position) this.set(this.size() - 1, null) //Adjust (correct) size (decrement) Decrement size //Return removed element return elem
//Get first Let elem = get and hold element to remove removed element e.g. "this.get(0)" //Shift Shift all elements (starting at index position 1) to left //Set last to null (clear unused slot/position) this.set(this.size() - 1, null) //Adjust (correct) size (decrement) Decrement size //Return removed element return elem
If (isEmpty()) Throw runtime exception Return this.elements[0];
public E first() {
if (isEmpty())
throwRuntime(emptyAccessMsg());
return this.elements[0];
}
public E first() { if (isEmpty()) throwRuntime(emptyAccessMsg()); return this.elements[0]; }
public E first() { if (isEmpty()) throwRuntime(emptyAccessMsg()); return this.elements[0]; }
//Given object "z" to search for Loop (scan) through the elements in order If an element matches "z" Return index //None found Return -1