// Constructor function Vector(size) { if (size == 0) { size = 10; } this.theArray = new Array(size); this.index = 0;
}
// size() -- returns the size of the vector function size() { return this.theArray.length; }
// getElement() -- returns the current element function getElement() { if (this.theArray != null) { return this.theArray[index]; } }
// getLastElement() -- returns the last element function getLastElement() { if (this.theArray{this.theArray.length - 1] != null) { return this.theArray[this.theArray.length - 1]; } }
// getFirstElement() -- returns the first element function getFirstElement() { if (this.theArray[0] != null) { return this.theArray[0]; } }
// addElement() -- adds a element at the end of the Vector function addElement(vObject) { if(this.theArray.length == this.index) { resize(10); }
this.theArray[index] = vObject; }
// addElementAt -- adds a element at a certain index of the Vector function addElementAt(vObject, i) { while (this.theArray.length <= i) { resize(10); }
this.theArray[i] = vObject; }
// removeElementAt() -- removes and returns the element at a certain index function removeElementAt() {
}
// removeAllElements() -- removes all elements in the Vector function removeAllElements() { delete this.theArray }
// resize() -- increases the size of the Vector function resize() {
}
// toString() -- returns a string rep. of the Vector function toString() {
}
</SCRIPT> </HEAD>
Related Scripts with Example Source Code in same category :