From e44a7e37b6c7b5961adaffc62b9042b8d442938e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 13 Nov 2008 09:49:11 +0000 Subject: New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f --- includes/js/dojox/collections/ArrayList.js | 133 +++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 includes/js/dojox/collections/ArrayList.js (limited to 'includes/js/dojox/collections/ArrayList.js') diff --git a/includes/js/dojox/collections/ArrayList.js b/includes/js/dojox/collections/ArrayList.js new file mode 100644 index 0000000..d57f6e7 --- /dev/null +++ b/includes/js/dojox/collections/ArrayList.js @@ -0,0 +1,133 @@ +if(!dojo._hasResource["dojox.collections.ArrayList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.collections.ArrayList"] = true; +dojo.provide("dojox.collections.ArrayList"); +dojo.require("dojox.collections._base"); + +dojox.collections.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 + // return an array with function applied to all elements + 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||",")); + }; +}; + +} -- cgit v1.2.3