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 |
public int size() {
return this.size;
}
//"array" is convenience var array = this.elements //Get first elem = get(0) //ShiftAllLeft Loop from 2 to (this.size - 1) array[i-1] = array[i] //Set last to null array[this.size - 1] = null Return elem;
//"array" is convenience var array = this.elements //Get first elem = get(0) //ShiftAllLeft Loop from 2 to (this.size - 1) array[i-1] = array[i] //Set last to null array[this.size - 1] = null 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