define(["dojo/_base/kernel", "dojo/_base/array", "./_base"], function(dojo, darray, dxc){ dxc.ArrayList=function(/*array?*/ arr){ // summary: // Returns a new object of type dojox.collections.ArrayList var items=[]; if(arr) items=items.concat(arr); this.count=items.length; this.add=function(/*object*/ obj){ // summary: // Add an element to the collection. items.push(obj); this.count=items.length; }; this.addRange=function(/*array*/ a){ // summary: // Add a range of objects to the ArrayList if(a.getIterator){ var e=a.getIterator(); while(!e.atEnd()){ this.add(e.get()); } this.count=items.length; }else{ for(var i=0; i=0) { items.splice(i,1); } this.count=items.length; }; this.removeAt=function(/*int*/ i){ // summary: // Remove the element located at the given index. items.splice(i,1); this.count=items.length; }; this.reverse=function(){ // summary: // Reverse the internal array items.reverse(); }; this.sort=function(/*function?*/ fn){ // summary: // sort the internal array if(fn){ items.sort(fn); }else{ items.sort(); } }; this.setByIndex=function(/*int*/ i, /*object*/ obj){ // summary: // Set an element in the array by the passed index. items[i]=obj; this.count=items.length; }; this.toArray=function(){ // summary: // Return a new array with all of the items of the internal array concatenated. return [].concat(items); }; this.toString=function(/*string*/ delim){ // summary: // implementation of toString, follows [].toString(); return items.join((delim||",")); }; }; return dxc.ArrayList; });