elementcount++;
}
this.setelementat = function (index, element ){
//alert("setelementat");
if ( index > elementcount || index < 0 ){
alert( "indexoutofboundsexception, index: "+index+", size: " + elementcount );
return;
//throw (new error(-1,"indexoutofboundsexception, index: "+index+", size: " + elementcount));
}
elementdata[index] = element;
}
this.tostring = function(){
//alert("tostring()");
var str = "{";
for(var i=0;i<elementcount;i++){
if( i>0 ){
str += ",";
}
str += elementdata[i];
}
str += "}";
return str;
}
this.get = function(index){
//alert("elementat");
if ( index >= elementcount ) {
alert( "arrayindexoutofboundsexception, " + index + " >= " + elementcount );
return;
//throw ( new error( -1,"arrayindexoutofboundsexception, " + index + " >= " + elementcount ) );
}
return elementdata[index];
}
this.remove = function(index){
if ( index >= elementcount ) {
alert( "arrayindexoutofboundsexception, " + index + " >= " + elementcount );
//return;
throw ( new error( -1,"arrayindexoutofboundsexception, " + index + " >= " + elementcount ) );
}
var olddata = elementdata[index];
for( var i=index;i<elementcount - 1;i++ ){
elementdata[i] = elementdata[i+1];
}
elementdata[elementcount - 1] = null;
elementcount--;
return olddata;
}
this.isempty = function() {
return elementcount == 0;
}
this.indexof = function(elem) {
//alert("indexof");
for ( var i=0; i < elementcount; i++ ){
if (elementdata[i]==elem){
return i;
}
}
return -1;
}
this.lastindexof = function(elem) {
for (var i = elementcount-1; i >= 0; i--){
if ( elementdata[i]==elem ){
return i;
}
}
return -1;