aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/collections
diff options
context:
space:
mode:
Diffstat (limited to 'includes/js/dojox/collections')
-rw-r--r--includes/js/dojox/collections/ArrayList.js133
-rw-r--r--includes/js/dojox/collections/BinaryTree.js211
-rw-r--r--includes/js/dojox/collections/Dictionary.js116
-rw-r--r--includes/js/dojox/collections/Queue.js74
-rw-r--r--includes/js/dojox/collections/README39
-rw-r--r--includes/js/dojox/collections/Set.js89
-rw-r--r--includes/js/dojox/collections/SortedList.js198
-rw-r--r--includes/js/dojox/collections/Stack.js72
-rw-r--r--includes/js/dojox/collections/_base.js100
-rw-r--r--includes/js/dojox/collections/tests/ArrayList.js83
-rw-r--r--includes/js/dojox/collections/tests/BinaryTree.js83
-rw-r--r--includes/js/dojox/collections/tests/Dictionary.js82
-rw-r--r--includes/js/dojox/collections/tests/Queue.js49
-rw-r--r--includes/js/dojox/collections/tests/Set.js35
-rw-r--r--includes/js/dojox/collections/tests/SortedList.js168
-rw-r--r--includes/js/dojox/collections/tests/Stack.js49
-rw-r--r--includes/js/dojox/collections/tests/_base.js84
-rw-r--r--includes/js/dojox/collections/tests/collections.js19
-rw-r--r--includes/js/dojox/collections/tests/runTests.html9
19 files changed, 1693 insertions, 0 deletions
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<a.length; i++){
+ items.push(a[i]);
+ }
+ this.count=items.length;
+ }
+ };
+ this.clear=function(){
+ // summary
+ // Clear all elements out of the collection, and reset the count.
+ items.splice(0, items.length);
+ this.count=0;
+ };
+ this.clone=function(){
+ // summary
+ // Clone the array list
+ return new dojox.collections.ArrayList(items); // dojox.collections.ArrayList
+ };
+ this.contains=function(/* object */obj){
+ // summary
+ // Check to see if the passed object is a member in the ArrayList
+ for(var i=0; i < items.length; i++){
+ if(items[i] == obj) {
+ return true; // bool
+ }
+ }
+ return false; // bool
+ };
+ this.forEach=function(/* function */ fn, /* object? */ scope){
+ // summary
+ // functional iterator, following the mozilla spec.
+ dojo.forEach(items, fn, scope);
+ };
+ this.getIterator=function(){
+ // summary
+ // Get an Iterator for this object
+ return new dojox.collections.Iterator(items); // dojox.collections.Iterator
+ };
+ this.indexOf=function(/* object */obj){
+ // summary
+ // Return the numeric index of the passed object; will return -1 if not found.
+ for(var i=0; i < items.length; i++){
+ if(items[i] == obj) {
+ return i; // int
+ }
+ }
+ return -1; // int
+ };
+ this.insert=function(/* int */ i, /* object */ obj){
+ // summary
+ // Insert the passed object at index i
+ items.splice(i,0,obj);
+ this.count=items.length;
+ };
+ this.item=function(/* int */ i){
+ // summary
+ // return the element at index i
+ return items[i]; // object
+ };
+ this.remove=function(/* object */obj){
+ // summary
+ // Look for the passed object, and if found, remove it from the internal array.
+ var i=this.indexOf(obj);
+ if(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||","));
+ };
+};
+
+}
diff --git a/includes/js/dojox/collections/BinaryTree.js b/includes/js/dojox/collections/BinaryTree.js
new file mode 100644
index 0000000..edd9fbf
--- /dev/null
+++ b/includes/js/dojox/collections/BinaryTree.js
@@ -0,0 +1,211 @@
+if(!dojo._hasResource["dojox.collections.BinaryTree"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.BinaryTree"] = true;
+dojo.provide("dojox.collections.BinaryTree");
+dojo.require("dojox.collections._base");
+
+dojox.collections.BinaryTree=function(data){
+ function node(data, rnode, lnode){
+ this.value=data||null;
+ this.right=rnode||null;
+ this.left=lnode||null;
+ this.clone=function(){
+ var c=new node();
+ if(this.value.value){
+ c.value=this.value.clone();
+ }else{
+ c.value=this.value;
+ }
+ if(this.left!=null){
+ c.left=this.left.clone();
+ }
+ if(this.right!=null){
+ c.right=this.right.clone();
+ }
+ return c;
+ }
+ this.compare=function(n){
+ if(this.value>n.value){ return 1; }
+ if(this.value<n.value){ return -1; }
+ return 0;
+ }
+ this.compareData=function(d){
+ if(this.value>d){ return 1; }
+ if(this.value<d){ return -1; }
+ return 0;
+ }
+ }
+
+ function inorderTraversalBuildup(current, a){
+ if(current){
+ inorderTraversalBuildup(current.left, a);
+ a.push(current.value);
+ inorderTraversalBuildup(current.right, a);
+ }
+ }
+
+ function preorderTraversal(current, sep){
+ var s="";
+ if (current){
+ s=current.value.toString() + sep;
+ s+=preorderTraversal(current.left, sep);
+ s+=preorderTraversal(current.right, sep);
+ }
+ return s;
+ }
+ function inorderTraversal(current, sep){
+ var s="";
+ if (current){
+ s=inorderTraversal(current.left, sep);
+ s+=current.value.toString() + sep;
+ s+=inorderTraversal(current.right, sep);
+ }
+ return s;
+ }
+ function postorderTraversal(current, sep){
+ var s="";
+ if (current){
+ s=postorderTraversal(current.left, sep);
+ s+=postorderTraversal(current.right, sep);
+ s+=current.value.toString() + sep;
+ }
+ return s;
+ }
+
+ function searchHelper(current, data){
+ if(!current){ return null; }
+ var i=current.compareData(data);
+ if(i==0){ return current; }
+ if(i>0){ return searchHelper(current.left, data); }
+ else{ return searchHelper(current.right, data); }
+ }
+
+ this.add=function(data){
+ var n=new node(data);
+ var i;
+ var current=root;
+ var parent=null;
+ while(current){
+ i=current.compare(n);
+ if(i==0){ return; }
+ parent=current;
+ if(i>0){ current=current.left; }
+ else{ current=current.right; }
+ }
+ this.count++;
+ if(!parent){
+ root=n;
+ }else{
+ i=parent.compare(n);
+ if(i>0){
+ parent.left=n;
+ }else{
+ parent.right=n;
+ }
+ }
+ };
+ this.clear=function(){
+ root=null;
+ this.count=0;
+ };
+ this.clone=function(){
+ var c=new dojox.collections.BinaryTree();
+ var itr=this.getIterator();
+ while(!itr.atEnd()){
+ c.add(itr.get());
+ }
+ return c;
+ };
+ this.contains=function(data){
+ return this.search(data) != null;
+ };
+ this.deleteData=function(data){
+ var current=root;
+ var parent=null;
+ var i=current.compareData(data);
+ while(i!=0&&current!=null){
+ if(i>0){
+ parent=current;
+ current=current.left;
+ }else if(i<0){
+ parent=current;
+ current=current.right;
+ }
+ i=current.compareData(data);
+ }
+ if(!current){ return; }
+ this.count--;
+ if(!current.right){
+ if(!parent){
+ root=current.left;
+ }else{
+ i=parent.compare(current);
+ if(i>0){ parent.left=current.left; }
+ else if(i<0){ parent.right=current.left; }
+ }
+ }
+ else if(!current.right.left){
+ if(!parent){
+ root=current.right;
+ }else{
+ i=parent.compare(current);
+ if(i>0){ parent.left=current.right; }
+ else if(i<0){ parent.right=current.right; }
+ }
+ }
+ else{
+ var leftmost=current.right.left;
+ var lmParent=current.right;
+ while(leftmost.left!=null){
+ lmParent=leftmost;
+ leftmost=leftmost.left;
+ }
+ lmParent.left=leftmost.right;
+ leftmost.left=current.left;
+ leftmost.right=current.right;
+ if(!parent){
+ root=leftmost;
+ }else{
+ i=parent.compare(current);
+ if(i>0){ parent.left=leftmost; }
+ else if(i<0){ parent.right=leftmost; }
+ }
+ }
+ };
+ this.getIterator=function(){
+ var a=[];
+ inorderTraversalBuildup(root, a);
+ return new dojox.collections.Iterator(a);
+ };
+ this.search=function(data){
+ return searchHelper(root, data);
+ };
+ this.toString=function(order, sep){
+ if(!order){ order=dojox.collections.BinaryTree.TraversalMethods.Inorder; }
+ if(!sep){ sep=","; }
+ var s="";
+ switch(order){
+ case dojox.collections.BinaryTree.TraversalMethods.Preorder:
+ s=preorderTraversal(root, sep);
+ break;
+ case dojox.collections.BinaryTree.TraversalMethods.Inorder:
+ s=inorderTraversal(root, sep);
+ break;
+ case dojox.collections.BinaryTree.TraversalMethods.Postorder:
+ s=postorderTraversal(root, sep);
+ break;
+ };
+ if(s.length==0){ return ""; }
+ else{ return s.substring(0, s.length - sep.length); }
+ };
+
+ this.count=0;
+ var root=this.root=null;
+ if(data){
+ this.add(data);
+ }
+}
+dojox.collections.BinaryTree.TraversalMethods={
+ Preorder: 1, Inorder: 2, Postorder: 3
+};
+
+}
diff --git a/includes/js/dojox/collections/Dictionary.js b/includes/js/dojox/collections/Dictionary.js
new file mode 100644
index 0000000..8213790
--- /dev/null
+++ b/includes/js/dojox/collections/Dictionary.js
@@ -0,0 +1,116 @@
+if(!dojo._hasResource["dojox.collections.Dictionary"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.Dictionary"] = true;
+dojo.provide("dojox.collections.Dictionary");
+dojo.require("dojox.collections._base");
+
+dojox.collections.Dictionary=function(/* dojox.collections.Dictionary? */dictionary){
+ // summary
+ // Returns an object of type dojox.collections.Dictionary
+ var items={};
+ this.count=0;
+
+ // comparator for property addition and access.
+ var testObject={};
+
+ this.add=function(/* string */k, /* object */v){
+ // summary
+ // Add a new item to the Dictionary.
+ var b=(k in items);
+ items[k]=new dojox.collections.DictionaryEntry(k,v);
+ if(!b){
+ this.count++;
+ }
+ };
+ this.clear=function(){
+ // summary
+ // Clears the internal dictionary.
+ items={};
+ this.count=0;
+ };
+ this.clone=function(){
+ // summary
+ // Returns a new instance of dojox.collections.Dictionary; note the the dictionary is a clone but items might not be.
+ return new dojox.collections.Dictionary(this); // dojox.collections.Dictionary
+ };
+ this.contains=this.containsKey=function(/* string */k){
+ // summary
+ // Check to see if the dictionary has an entry at key "k".
+ if(testObject[k]){
+ return false; // bool
+ }
+ return (items[k]!=null); // bool
+ };
+ this.containsValue=function(/* object */v){
+ // summary
+ // Check to see if the dictionary has an entry with value "v".
+ var e=this.getIterator();
+ while(e.get()){
+ if(e.element.value==v){
+ return true; // bool
+ }
+ }
+ return false; // bool
+ };
+ this.entry=function(/* string */k){
+ // summary
+ // Accessor method; similar to dojox.collections.Dictionary.item but returns the actual Entry object.
+ return items[k]; // dojox.collections.DictionaryEntry
+ };
+ this.forEach=function(/* function */ fn, /* object? */ scope){
+ // summary
+ // functional iterator, following the mozilla spec.
+ var a=[]; // Create an indexing array
+ for(var p in items) {
+ if(!testObject[p]){
+ a.push(items[p]); // fill it up
+ }
+ }
+ dojo.forEach(a, fn, scope);
+ };
+ this.getKeyList=function(){
+ // summary
+ // Returns an array of the keys in the dictionary.
+ return (this.getIterator()).map(function(entry){
+ return entry.key;
+ }); // array
+ };
+ this.getValueList=function(){
+ // summary
+ // Returns an array of the values in the dictionary.
+ return (this.getIterator()).map(function(entry){
+ return entry.value;
+ }); // array
+ };
+ this.item=function(/* string */k){
+ // summary
+ // Accessor method.
+ if(k in items){
+ return items[k].valueOf(); // object
+ }
+ return undefined; // object
+ };
+ this.getIterator=function(){
+ // summary
+ // Gets a dojox.collections.DictionaryIterator for iteration purposes.
+ return new dojox.collections.DictionaryIterator(items); // dojox.collections.DictionaryIterator
+ };
+ this.remove=function(/* string */k){
+ // summary
+ // Removes the item at k from the internal collection.
+ if(k in items && !testObject[k]){
+ delete items[k];
+ this.count--;
+ return true; // bool
+ }
+ return false; // bool
+ };
+
+ if (dictionary){
+ var e=dictionary.getIterator();
+ while(e.get()) {
+ this.add(e.element.key, e.element.value);
+ }
+ }
+};
+
+}
diff --git a/includes/js/dojox/collections/Queue.js b/includes/js/dojox/collections/Queue.js
new file mode 100644
index 0000000..5fa4a5d
--- /dev/null
+++ b/includes/js/dojox/collections/Queue.js
@@ -0,0 +1,74 @@
+if(!dojo._hasResource["dojox.collections.Queue"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.Queue"] = true;
+dojo.provide("dojox.collections.Queue");
+dojo.require("dojox.collections._base");
+
+dojox.collections.Queue=function(/* array? */arr){
+ // summary
+ // return an object of type dojox.collections.Queue
+ var q=[];
+ if (arr){
+ q=q.concat(arr);
+ }
+ this.count=q.length;
+ this.clear=function(){
+ // summary
+ // clears the internal collection
+ q=[];
+ this.count=q.length;
+ };
+ this.clone=function(){
+ // summary
+ // creates a new Queue based on this one
+ return new dojox.collections.Queue(q); // dojox.collections.Queue
+ };
+ this.contains=function(/* object */ o){
+ // summary
+ // Check to see if the passed object is an element in this queue
+ for(var i=0; i<q.length; i++){
+ if (q[i]==o){
+ return true; // bool
+ }
+ }
+ return false; // bool
+ };
+ this.copyTo=function(/* array */ arr, /* int */ i){
+ // summary
+ // Copy the contents of this queue into the passed array at index i.
+ arr.splice(i,0,q);
+ };
+ this.dequeue=function(){
+ // summary
+ // shift the first element off the queue and return it
+ var r=q.shift();
+ this.count=q.length;
+ return r; // object
+ };
+ this.enqueue=function(/* object */ o){
+ // summary
+ // put the passed object at the end of the queue
+ this.count=q.push(o);
+ };
+ this.forEach=function(/* function */ fn, /* object? */ scope){
+ // summary
+ // functional iterator, following the mozilla spec.
+ dojo.forEach(q, fn, scope);
+ };
+ this.getIterator=function(){
+ // summary
+ // get an Iterator based on this queue.
+ return new dojox.collections.Iterator(q); // dojox.collections.Iterator
+ };
+ this.peek=function(){
+ // summary
+ // get the next element in the queue without altering the queue.
+ return q[0];
+ };
+ this.toArray=function(){
+ // summary
+ // return an array based on the internal array of the queue.
+ return [].concat(q);
+ };
+};
+
+}
diff --git a/includes/js/dojox/collections/README b/includes/js/dojox/collections/README
new file mode 100644
index 0000000..9cdadb5
--- /dev/null
+++ b/includes/js/dojox/collections/README
@@ -0,0 +1,39 @@
+-------------------------------------------------------------------------------
+DojoX Collections
+-------------------------------------------------------------------------------
+Version 0.9
+Release date: 05/27/2007
+-------------------------------------------------------------------------------
+Project state: stable
+-------------------------------------------------------------------------------
+Project authors
+ Tom Trenka (ttrenka@gmail.com)
+-------------------------------------------------------------------------------
+Project description
+
+DojoX Collections is the port of the original Dojo 0.4.x collection classes.
+It is intended for use by people who are looking for a little bit more
+functionality out of common collections, like ArrayLists or Dictionaries.
+
+Included are the Iterator and DictionaryIterator classes, both of which can
+operate on standard arrays and objects (respectively).
+-------------------------------------------------------------------------------
+Dependencies:
+
+DojoX Collections has no dependencies, outside of Dojo Core.
+-------------------------------------------------------------------------------
+Documentation
+
+See the API documentation for Dojo (http://dojotoolkit.org/api).
+-------------------------------------------------------------------------------
+Installation instructions
+
+Grab the following from the Dojo SVN Repository:
+http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/collections.js
+http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/collections/*
+
+Install into the following directory structure:
+/dojox/collections/
+
+...which should be at the same level as your Dojo checkout.
+-------------------------------------------------------------------------------
diff --git a/includes/js/dojox/collections/Set.js b/includes/js/dojox/collections/Set.js
new file mode 100644
index 0000000..6796c1d
--- /dev/null
+++ b/includes/js/dojox/collections/Set.js
@@ -0,0 +1,89 @@
+if(!dojo._hasResource["dojox.collections.Set"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.Set"] = true;
+dojo.provide("dojox.collections.Set");
+dojo.require("dojox.collections.ArrayList");
+
+(function(){
+ var dxc=dojox.collections;
+ dxc.Set=new (function(){
+ function conv(arr){
+ if(arr.constructor==Array){
+ return new dojox.collections.ArrayList(arr); // dojox.collections.ArrayList
+ }
+ return arr; // dojox.collections.ArrayList
+ }
+ this.union = function(/* array */setA, /* array */setB){
+ // summary
+ // Return the union of the two passed sets.
+ setA=conv(setA);
+ setB=conv(setB);
+ var result = new dojox.collections.ArrayList(setA.toArray());
+ var e = setB.getIterator();
+ while(!e.atEnd()){
+ var item=e.get();
+ if(!result.contains(item)){
+ result.add(item);
+ }
+ }
+ return result; // dojox.collections.ArrayList
+ };
+ this.intersection = function(/* array */setA, /* array */setB){
+ // summary
+ // Return the intersection of the two passed sets.
+ setA=conv(setA);
+ setB=conv(setB);
+ var result = new dojox.collections.ArrayList();
+ var e = setB.getIterator();
+ while(!e.atEnd()){
+ var item=e.get();
+ if(setA.contains(item)){
+ result.add(item);
+ }
+ }
+ return result; // dojox.collections.ArrayList
+ };
+ this.difference = function(/* array */setA, /* array */setB){
+ // summary
+ // Returns everything in setA that is not in setB.
+ setA=conv(setA);
+ setB=conv(setB);
+ var result = new dojox.collections.ArrayList();
+ var e=setA.getIterator();
+ while(!e.atEnd()){
+ var item=e.get();
+ if(!setB.contains(item)){
+ result.add(item);
+ }
+ }
+ return result; // dojox.collections.ArrayList
+ };
+ this.isSubSet = function(/* array */setA, /* array */setB) {
+ // summary
+ // Returns if set B is a subset of set A.
+ setA=conv(setA);
+ setB=conv(setB);
+ var e = setA.getIterator();
+ while(!e.atEnd()){
+ if(!setB.contains(e.get())){
+ return false; // boolean
+ }
+ }
+ return true; // boolean
+ };
+ this.isSuperSet = function(/* array */setA, /* array */setB){
+ // summary
+ // Returns if set B is a superset of set A.
+ setA=conv(setA);
+ setB=conv(setB);
+ var e = setB.getIterator();
+ while(!e.atEnd()){
+ if(!setA.contains(e.get())){
+ return false; // boolean
+ }
+ }
+ return true; // boolean
+ };
+ })();
+})();
+
+}
diff --git a/includes/js/dojox/collections/SortedList.js b/includes/js/dojox/collections/SortedList.js
new file mode 100644
index 0000000..e9f1235
--- /dev/null
+++ b/includes/js/dojox/collections/SortedList.js
@@ -0,0 +1,198 @@
+if(!dojo._hasResource["dojox.collections.SortedList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.SortedList"] = true;
+dojo.provide("dojox.collections.SortedList");
+dojo.require("dojox.collections._base");
+
+dojox.collections.SortedList=function(/* object? */ dictionary){
+ // summary
+ // creates a collection that acts like a dictionary but is also internally sorted.
+ // Note that the act of adding any elements forces an internal resort, making this object potentially slow.
+ var _this=this;
+ var items={};
+ var q=[];
+ var sorter=function(a,b){
+ if (a.key > b.key) return 1;
+ if (a.key < b.key) return -1;
+ return 0;
+ };
+ var build=function(){
+ q=[];
+ var e=_this.getIterator();
+ while (!e.atEnd()){
+ q.push(e.get());
+ }
+ q.sort(sorter);
+ };
+ var testObject={};
+
+ this.count=q.length;
+ this.add=function(/* string */ k,/* object */v){
+ // summary
+ // add the passed value to the dictionary at location k
+ if (!items[k]) {
+ items[k]=new dojox.collections.DictionaryEntry(k,v);
+ this.count=q.push(items[k]);
+ q.sort(sorter);
+ }
+ };
+ this.clear=function(){
+ // summary
+ // clear the internal collections
+ items={};
+ q=[];
+ this.count=q.length;
+ };
+ this.clone=function(){
+ // summary
+ // create a clone of this sorted list
+ return new dojox.collections.SortedList(this); // dojox.collections.SortedList
+ };
+ this.contains=this.containsKey=function(/* string */ k){
+ // summary
+ // Check to see if the list has a location k
+ if(testObject[k]){
+ return false; // bool
+ }
+ return (items[k]!=null); // bool
+ };
+ this.containsValue=function(/* object */ o){
+ // summary
+ // Check to see if this list contains the passed object
+ var e=this.getIterator();
+ while (!e.atEnd()){
+ var item=e.get();
+ if(item.value==o){
+ return true; // bool
+ }
+ }
+ return false; // bool
+ };
+ this.copyTo=function(/* array */ arr, /* int */ i){
+ // summary
+ // copy the contents of the list into array arr at index i
+ var e=this.getIterator();
+ var idx=i;
+ while(!e.atEnd()){
+ arr.splice(idx,0,e.get());
+ idx++;
+ }
+ };
+ this.entry=function(/* string */ k){
+ // summary
+ // return the object at location k
+ return items[k]; // dojox.collections.DictionaryEntry
+ };
+ this.forEach=function(/* function */ fn, /* object? */ scope){
+ // summary
+ // functional iterator, following the mozilla spec.
+ dojo.forEach(q, fn, scope);
+ };
+ this.getByIndex=function(/* int */ i){
+ // summary
+ // return the item at index i
+ return q[i].valueOf(); // object
+ };
+ this.getIterator=function(){
+ // summary
+ // get an iterator for this object
+ return new dojox.collections.DictionaryIterator(items); // dojox.collections.DictionaryIterator
+ };
+ this.getKey=function(/* int */ i){
+ // summary
+ // return the key of the item at index i
+ return q[i].key;
+ };
+ this.getKeyList=function(){
+ // summary
+ // return an array of the keys set in this list
+ var arr=[];
+ var e=this.getIterator();
+ while (!e.atEnd()){
+ arr.push(e.get().key);
+ }
+ return arr; // array
+ };
+ this.getValueList=function(){
+ // summary
+ // return an array of values in this list
+ var arr=[];
+ var e=this.getIterator();
+ while (!e.atEnd()){
+ arr.push(e.get().value);
+ }
+ return arr; // array
+ };
+ this.indexOfKey=function(/* string */ k){
+ // summary
+ // return the index of the passed key.
+ for (var i=0; i<q.length; i++){
+ if (q[i].key==k){
+ return i; // int
+ }
+ }
+ return -1; // int
+ };
+ this.indexOfValue=function(/* object */ o){
+ // summary
+ // return the first index of object o
+ for (var i=0; i<q.length; i++){
+ if (q[i].value==o){
+ return i; // int
+ }
+ }
+ return -1; // int
+ };
+ this.item=function(/* string */ k){
+ // summary
+ // return the value of the object at location k.
+ if(k in items && !testObject[k]){
+ return items[k].valueOf(); // object
+ }
+ return undefined; // object
+ };
+ this.remove=function(/* string */k){
+ // summary
+ // remove the item at location k and rebuild the internal collections.
+ delete items[k];
+ build();
+ this.count=q.length;
+ };
+ this.removeAt=function(/* int */ i){
+ // summary
+ // remove the item at index i, and rebuild the internal collections.
+ delete items[q[i].key];
+ build();
+ this.count=q.length;
+ };
+ this.replace=function(/* string */ k, /* object */ v){
+ // summary
+ // Replace an existing item if it's there, and add a new one if not.
+ if (!items[k]){
+ // we're adding a new object, return false
+ this.add(k,v);
+ return false; // bool
+ }else{
+ // we're replacing an object, return true
+ items[k]=new dojox.collections.DictionaryEntry(k,v);
+ build();
+ return true; // bool
+ }
+ };
+ this.setByIndex=function(/* int */ i, /* object */ o){
+ // summary
+ // set an item by index
+ items[q[i].key].value=o;
+ build();
+ this.count=q.length;
+ };
+ if (dictionary){
+ var e=dictionary.getIterator();
+ while (!e.atEnd()){
+ var item=e.get();
+ q[q.length]=items[item.key]=new dojox.collections.DictionaryEntry(item.key,item.value);
+ }
+ q.sort(sorter);
+ }
+}
+
+}
diff --git a/includes/js/dojox/collections/Stack.js b/includes/js/dojox/collections/Stack.js
new file mode 100644
index 0000000..999bbef
--- /dev/null
+++ b/includes/js/dojox/collections/Stack.js
@@ -0,0 +1,72 @@
+if(!dojo._hasResource["dojox.collections.Stack"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.Stack"] = true;
+dojo.provide("dojox.collections.Stack");
+dojo.require("dojox.collections._base");
+
+dojox.collections.Stack=function(/* array? */arr){
+ // summary
+ // returns an object of type dojox.collections.Stack
+ var q=[];
+ if (arr) q=q.concat(arr);
+ this.count=q.length;
+ this.clear=function(){
+ // summary
+ // Clear the internal array and reset the count
+ q=[];
+ this.count=q.length;
+ };
+ this.clone=function(){
+ // summary
+ // Create and return a clone of this Stack
+ return new dojox.collections.Stack(q);
+ };
+ this.contains=function(/* object */o){
+ // summary
+ // check to see if the stack contains object o
+ for (var i=0; i<q.length; i++){
+ if (q[i] == o){
+ return true; // bool
+ }
+ }
+ return false; // bool
+ };
+ this.copyTo=function(/* array */ arr, /* int */ i){
+ // summary
+ // copy the stack into array arr at index i
+ arr.splice(i,0,q);
+ };
+ this.forEach=function(/* function */ fn, /* object? */ scope){
+ // summary
+ // functional iterator, following the mozilla spec.
+ dojo.forEach(q, fn, scope);
+ };
+ this.getIterator=function(){
+ // summary
+ // get an iterator for this collection
+ return new dojox.collections.Iterator(q); // dojox.collections.Iterator
+ };
+ this.peek=function(){
+ // summary
+ // Return the next item without altering the stack itself.
+ return q[(q.length-1)]; // object
+ };
+ this.pop=function(){
+ // summary
+ // pop and return the next item on the stack
+ var r=q.pop();
+ this.count=q.length;
+ return r; // object
+ };
+ this.push=function(/* object */ o){
+ // summary
+ // Push object o onto the stack
+ this.count=q.push(o);
+ };
+ this.toArray=function(){
+ // summary
+ // create and return an array based on the internal collection
+ return [].concat(q); // array
+ };
+}
+
+}
diff --git a/includes/js/dojox/collections/_base.js b/includes/js/dojox/collections/_base.js
new file mode 100644
index 0000000..28862d5
--- /dev/null
+++ b/includes/js/dojox/collections/_base.js
@@ -0,0 +1,100 @@
+if(!dojo._hasResource["dojox.collections._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections._base"] = true;
+dojo.provide("dojox.collections._base");
+
+dojox.collections.DictionaryEntry=function(/* string */k, /* object */v){
+ // summary
+ // return an object of type dojox.collections.DictionaryEntry
+ this.key=k;
+ this.value=v;
+ this.valueOf=function(){
+ return this.value; // object
+ };
+ this.toString=function(){
+ return String(this.value); // string
+ };
+}
+
+/* Iterators
+ * The collections.Iterators (Iterator and DictionaryIterator) are built to
+ * work with the Collections included in this module. However, they *can*
+ * be used with arrays and objects, respectively, should one choose to do so.
+ */
+dojox.collections.Iterator=function(/* array */arr){
+ // summary
+ // return an object of type dojox.collections.Iterator
+ var a=arr;
+ var position=0;
+ this.element=a[position]||null;
+ this.atEnd=function(){
+ // summary
+ // Test to see if the internal cursor has reached the end of the internal collection.
+ return (position>=a.length); // bool
+ };
+ this.get=function(){
+ // summary
+ // Get the next member in the collection.
+ if(this.atEnd()){
+ return null; // object
+ }
+ this.element=a[position++];
+ return this.element; // object
+ };
+ this.map=function(/* function */fn, /* object? */scope){
+ // summary
+ // Functional iteration with optional scope.
+ return dojo.map(a, fn, scope);
+ };
+ this.reset=function(){
+ // summary
+ // reset the internal cursor.
+ position=0;
+ this.element=a[position];
+ };
+}
+
+/* Notes:
+ * The DictionaryIterator no longer supports a key and value property;
+ * the reality is that you can use this to iterate over a JS object
+ * being used as a hashtable.
+ */
+dojox.collections.DictionaryIterator=function(/* object */obj){
+ // summary
+ // return an object of type dojox.collections.DictionaryIterator
+ var a=[]; // Create an indexing array
+ var testObject={};
+ for(var p in obj){
+ if(!testObject[p]){
+ a.push(obj[p]); // fill it up
+ }
+ }
+ var position=0;
+ this.element=a[position]||null;
+ this.atEnd=function(){
+ // summary
+ // Test to see if the internal cursor has reached the end of the internal collection.
+ return (position>=a.length); // bool
+ };
+ this.get=function(){
+ // summary
+ // Get the next member in the collection.
+ if(this.atEnd()){
+ return null; // object
+ }
+ this.element=a[position++];
+ return this.element; // object
+ };
+ this.map=function(/* function */fn, /* object? */scope){
+ // summary
+ // Functional iteration with optional scope.
+ return dojo.map(a, fn, scope);
+ };
+ this.reset=function() {
+ // summary
+ // reset the internal cursor.
+ position=0;
+ this.element=a[position];
+ };
+};
+
+}
diff --git a/includes/js/dojox/collections/tests/ArrayList.js b/includes/js/dojox/collections/tests/ArrayList.js
new file mode 100644
index 0000000..2645238
--- /dev/null
+++ b/includes/js/dojox/collections/tests/ArrayList.js
@@ -0,0 +1,83 @@
+if(!dojo._hasResource["dojox.collections.tests.ArrayList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.tests.ArrayList"] = true;
+dojo.provide("dojox.collections.tests.ArrayList");
+dojo.require("dojox.collections.ArrayList");
+
+tests.register("dojox.collections.tests.ArrayList", [
+ function testCtor(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ t.assertEqual(4, al.count);
+ },
+ function testAdd(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ al.add("carp");
+ t.assertEqual("foo,bar,test,bull,carp", al.toString());
+ al.addRange(["oof","rab"]);
+ t.assertEqual("foo,bar,test,bull,carp,oof,rab", al.toString());
+ },
+ function testClear(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ al.clear();
+ t.assertEqual(0, al.count);
+ },
+ function testClone(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ var cloned=al.clone();
+ t.assertEqual(al.toString(), cloned.toString());
+ },
+ function testContains(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ t.assertTrue(al.contains("bar"));
+ t.assertFalse(al.contains("faz"));
+ },
+ function testGetIterator(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ var itr=al.getIterator();
+ while(!itr.atEnd()){
+ itr.get();
+ }
+ t.assertEqual("bull", itr.element);
+ },
+ function testIndexOf(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ t.assertEqual(1, al.indexOf("bar"));
+ },
+ function testInsert(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ al.insert(2, "baz");
+ t.assertEqual(2, al.indexOf("baz"));
+ },
+ function testItem(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ t.assertEqual("test", al.item(2));
+ },
+ function testRemove(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ al.remove("bar");
+ t.assertEqual("foo,test,bull", al.toString());
+ t.assertEqual(3, al.count);
+ },
+ function testRemoveAt(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ al.removeAt(3);
+ t.assertEqual("foo,bar,test", al.toString());
+ t.assertEqual(3, al.count);
+ },
+ function testReverse(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ al.reverse();
+ t.assertEqual("bull,test,bar,foo", al.toString());
+ },
+ function testSort(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ al.sort();
+ t.assertEqual("bar,bull,foo,test", al.toString());
+ },
+ function testToArray(t){
+ var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]);
+ var a=al.toArray();
+ t.assertEqual(a.join(","), al.toString());
+ }
+]);
+
+}
diff --git a/includes/js/dojox/collections/tests/BinaryTree.js b/includes/js/dojox/collections/tests/BinaryTree.js
new file mode 100644
index 0000000..48acaa4
--- /dev/null
+++ b/includes/js/dojox/collections/tests/BinaryTree.js
@@ -0,0 +1,83 @@
+if(!dojo._hasResource["dojox.collections.tests.BinaryTree"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.tests.BinaryTree"] = true;
+dojo.provide("dojox.collections.tests.BinaryTree");
+dojo.require("dojox.collections.BinaryTree");
+
+tests.register("dojox.collections.tests.BinaryTree", [
+ function testCtor(t){
+ var bt=new dojox.collections.BinaryTree("foo");
+ t.assertTrue(bt instanceof dojox.collections.BinaryTree);
+ },
+ function testAdd(t){
+ var bt=new dojox.collections.BinaryTree("foo");
+ bt.add("bar");
+ bt.add("baz");
+ bt.add("buck");
+ bt.add("shot");
+ bt.add("apple");
+ t.assertEqual("apple,bar,baz,buck,foo,shot",bt.toString());
+ },
+ function testClear(t){
+ var bt=new dojox.collections.BinaryTree("foo");
+ bt.add("bar");
+ bt.add("baz");
+ bt.add("buck");
+ bt.add("shot");
+ bt.add("apple");
+ bt.clear();
+ t.assertEqual(bt.count, 0);
+ },
+ function testClone(t){
+ var bt=new dojox.collections.BinaryTree("foo");
+ bt.add("bar");
+ bt.add("baz");
+ bt.add("buck");
+ bt.add("shot");
+ bt.add("apple");
+ var bt2=bt.clone();
+ t.assertEqual(bt2.count, 6);
+ t.assertEqual(bt.toString(), bt2.toString());
+ },
+ function testContains(t){
+ var bt=new dojox.collections.BinaryTree("foo");
+ bt.add("bar");
+ bt.add("baz");
+ bt.add("buck");
+ bt.add("shot");
+ bt.add("apple");
+ t.assertTrue(bt.contains("buck"));
+ t.assertFalse(bt.contains("duck"));
+ },
+ function testDeleteData(t){
+ var bt=new dojox.collections.BinaryTree("foo");
+ bt.add("bar");
+ bt.add("baz");
+ bt.add("buck");
+ bt.add("shot");
+ bt.add("apple");
+ bt.deleteData("buck");
+ t.assertEqual("apple,bar,baz,foo,shot",bt.toString());
+ },
+ function testGetIterator(t){
+ var bt=new dojox.collections.BinaryTree("foo");
+ bt.add("bar");
+ bt.add("baz");
+ bt.add("buck");
+ bt.add("shot");
+ bt.add("apple");
+ var itr=bt.getIterator();
+ while(!itr.atEnd()){ itr.get(); }
+ t.assertEqual("shot", itr.element);
+ },
+ function testSearch(t){
+ var bt=new dojox.collections.BinaryTree("foo");
+ bt.add("bar");
+ bt.add("baz");
+ bt.add("buck");
+ bt.add("shot");
+ bt.add("apple");
+ t.assertEqual("buck", bt.search("buck").value);
+ }
+]);
+
+}
diff --git a/includes/js/dojox/collections/tests/Dictionary.js b/includes/js/dojox/collections/tests/Dictionary.js
new file mode 100644
index 0000000..7bde6ee
--- /dev/null
+++ b/includes/js/dojox/collections/tests/Dictionary.js
@@ -0,0 +1,82 @@
+if(!dojo._hasResource["dojox.collections.tests.Dictionary"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.tests.Dictionary"] = true;
+dojo.provide("dojox.collections.tests.Dictionary");
+dojo.require("dojox.collections.Dictionary");
+
+tests.register("dojox.collections.tests.Dictionary", [
+ function testCtor(t){
+ var d=new dojox.collections.Dictionary();
+ t.assertTrue(d instanceof dojox.collections.Dictionary);
+ },
+ function testAdd(t){
+ var d=new dojox.collections.Dictionary();
+ d.add("foo","bar");
+ t.assertEqual("bar", d.item("foo").valueOf());
+ },
+ function testClear(t){
+ var d=new dojox.collections.Dictionary();
+ d.add("foo","bar");
+ d.clear()
+ t.assertEqual(0, d.count);
+ },
+ function testClone(t){
+ var d=new dojox.collections.Dictionary();
+ d.add("baz","fab");
+ d.add("buck","shot");
+ d.add("apple","orange");
+ var d2 = d.clone();
+ t.assertTrue(d2.contains("baz"));
+ },
+ function testContains(t){
+ var d=new dojox.collections.Dictionary();
+ d.add("foo","bar");
+ d.add("baz","fab");
+ d.add("buck","shot");
+ d.add("apple","orange");
+ t.assertTrue(d.contains("baz"));
+ },
+ function testContainsKey(t){
+ var d=new dojox.collections.Dictionary();
+ d.add("foo","bar");
+ d.add("baz","fab");
+ d.add("buck","shot");
+ d.add("apple","orange");
+ t.assertTrue(d.containsKey("buck"));
+ },
+ function testContainsValue(t){
+ var d=new dojox.collections.Dictionary();
+ d.add("foo","bar");
+ d.add("baz","fab");
+ d.add("buck","shot");
+ d.add("apple","orange");
+ t.assertTrue(d.containsValue("shot"));
+ },
+ function testGetKeyList(t){
+ var d=new dojox.collections.Dictionary();
+ d.add("foo","bar");
+ d.add("baz","fab");
+ d.add("buck","shot");
+ d.add("apple","orange");
+ t.assertEqual("foo,baz,buck,apple", d.getKeyList().join(","));
+ },
+ function testGetValueList(t){
+ var d=new dojox.collections.Dictionary();
+ d.add("foo","bar");
+ d.add("baz","fab");
+ d.add("buck","shot");
+ d.add("apple","orange");
+ t.assertEqual("bar,fab,shot,orange", d.getValueList().join(","));
+ },
+ function testRemove(t){
+ var d=new dojox.collections.Dictionary();
+ d.add("foo","bar");
+ d.add("baz","fab");
+ d.add("buck","shot");
+ d.add("apple","orange");
+ d.remove("baz");
+ t.assertEqual(3, d.count);
+ t.assertEqual(undefined, d.item("baz"));
+ }
+]);
+
+}
diff --git a/includes/js/dojox/collections/tests/Queue.js b/includes/js/dojox/collections/tests/Queue.js
new file mode 100644
index 0000000..5ac61bc
--- /dev/null
+++ b/includes/js/dojox/collections/tests/Queue.js
@@ -0,0 +1,49 @@
+if(!dojo._hasResource["dojox.collections.tests.Queue"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.tests.Queue"] = true;
+dojo.provide("dojox.collections.tests.Queue");
+dojo.require("dojox.collections.Queue");
+
+tests.register("dojox.collections.tests.Queue", [
+ function testCtor(t){
+ var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
+ t.assertEqual(4, q.count);
+ },
+ function testClear(t){
+ var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
+ q.clear();
+ t.assertEqual(0, q.count);
+ },
+ function testClone(t){
+ var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
+ var cloned=q.clone();
+ t.assertEqual(q.count, cloned.count);
+ t.assertEqual(q.toArray().join(), cloned.toArray().join());
+ },
+ function testContains(t){
+ var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
+ t.assertTrue(q.contains("bar"));
+ t.assertFalse(q.contains("faz"));
+ },
+ function testGetIterator(t){
+ var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
+ var itr=q.getIterator();
+ while(!itr.atEnd()){ itr.get(); }
+ t.assertEqual("bull", itr.element);
+ },
+ function testPeek(t){
+ var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
+ t.assertEqual("foo", q.peek());
+ },
+ function testDequeue(t){
+ var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
+ t.assertEqual("foo", q.dequeue());
+ t.assertEqual("bar,test,bull", q.toArray().join(","));
+ },
+ function testEnqueue(t){
+ var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
+ q.enqueue("bull");
+ t.assertEqual("bull", q.toArray().pop());
+ }
+]);
+
+}
diff --git a/includes/js/dojox/collections/tests/Set.js b/includes/js/dojox/collections/tests/Set.js
new file mode 100644
index 0000000..d548223
--- /dev/null
+++ b/includes/js/dojox/collections/tests/Set.js
@@ -0,0 +1,35 @@
+if(!dojo._hasResource["dojox.collections.tests.Set"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.tests.Set"] = true;
+dojo.provide("dojox.collections.tests.Set");
+dojo.require("dojox.collections.Set");
+
+(function(){
+ var dxcs=dojox.collections.Set;
+ var a = ["apple","bear","candy","donut","epiphite","frank"];
+ var b = ["bear","epiphite","google","happy","joy"];
+ tests.register("dojox.collections.tests.Set", [
+ function testUnion(t){
+ var union=dxcs.union(a,b);
+ t.assertEqual("apple,bear,candy,donut,epiphite,frank,google,happy,joy", union.toArray().join(','));
+ },
+ function testIntersection(t){
+ var itsn=dxcs.intersection(a,b);
+ t.assertEqual("bear,epiphite", itsn.toArray().join(","));
+ t.assertEqual("bear", dxcs.intersection(["bear","apple"], ["bear"]));
+ },
+ function testDifference(t){
+ var d=dxcs.difference(a,b);
+ t.assertEqual("apple,candy,donut,frank",d.toArray().join(','));
+ },
+ function testIsSubSet(t){
+ t.assertFalse(dxcs.isSubSet(a,["bear","candy"]));
+ t.assertTrue(dxcs.isSubSet(["bear","candy"],a));
+ },
+ function testIsSuperSet(t){
+ t.assertTrue(dxcs.isSuperSet(a,["bear","candy"]));
+ t.assertFalse(dxcs.isSuperSet(["bear","candy"],a));
+ }
+ ]);
+})();
+
+}
diff --git a/includes/js/dojox/collections/tests/SortedList.js b/includes/js/dojox/collections/tests/SortedList.js
new file mode 100644
index 0000000..dfb4ffa
--- /dev/null
+++ b/includes/js/dojox/collections/tests/SortedList.js
@@ -0,0 +1,168 @@
+if(!dojo._hasResource["dojox.collections.tests.SortedList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.tests.SortedList"] = true;
+dojo.provide("dojox.collections.tests.SortedList");
+dojo.require("dojox.collections.SortedList");
+
+tests.register("dojox.collections.tests.SortedList", [
+ function testCtor(t){
+ var sl=new dojox.collections.SortedList();
+ t.assertTrue(sl instanceof dojox.collections.SortedList);
+ },
+ function testAdd(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ t.assertEqual("bar", sl.item("foo").valueOf());
+ },
+ function testClear(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.clear();
+ t.assertEqual(0, sl.count);
+ },
+ function testClone(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ var sl2=sl.clone();
+ t.assertTrue(sl2.contains("baz"));
+ },
+ function testContains(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ t.assertTrue(sl.contains("baz"));
+ t.assertFalse(sl.contains("faz"));
+ },
+ function testContainsKey(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ t.assertTrue(sl.containsKey("buck"));
+ t.assertFalse(sl.containsKey("faz"));
+ },
+ function testContainsValue(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ t.assertTrue(sl.containsValue("shot"));
+ t.assertFalse(sl.containsValue("faz"));
+ },
+ function testGetKeyList(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ t.assertEqual("foo,baz,buck,apple",sl.getKeyList().join(','));
+ },
+ function testGetValueList(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ t.assertEqual("bar,fab,shot,orange",sl.getValueList().join(','));
+ },
+ function testCopyTo(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ var arr=["bek"];
+ sl.copyTo(arr,0);
+ t.assertEqual("bar,fab,shot,orange,bek", arr.join(','));
+ },
+ function testGetByIndex(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ t.assertEqual("shot", sl.getByIndex(2));
+ },
+ function testGetKey(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ t.assertEqual("apple", sl.getKey(0));
+ },
+ function testIndexOfKey(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ t.assertEqual(0, sl.indexOfKey("apple"));
+ },
+ function testIndexOfValue(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ t.assertEqual(3, sl.indexOfValue("bar"));
+ },
+ function testRemove(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ sl.remove("baz");
+ t.assertEqual(3, sl.count);
+ t.assertEqual(undefined, sl.item("baz"));
+ },
+ function testRemoveAt(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ sl.removeAt(2);
+ t.assertEqual(undefined, sl.item("buck"));
+ },
+ function testReplace(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ sl.replace("buck","dollar");
+ t.assertEqual(sl.item("buck").valueOf(), "dollar");
+ },
+ function testSetByIndex(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+ sl.setByIndex(0, "bar");
+ t.assertEqual("bar", sl.getByIndex(0));
+ },
+ function testSorting(t){
+ var sl=new dojox.collections.SortedList();
+ sl.add("foo","bar");
+ sl.add("baz","fab");
+ sl.add("buck","shot");
+ sl.add("apple","orange");
+
+ var a=[];
+ sl.forEach(function(item){
+ a.push(item);
+ });
+ t.assertEqual("orange,fab,shot,bar", a.join());
+ }
+]);
+
+}
diff --git a/includes/js/dojox/collections/tests/Stack.js b/includes/js/dojox/collections/tests/Stack.js
new file mode 100644
index 0000000..7bf4e79
--- /dev/null
+++ b/includes/js/dojox/collections/tests/Stack.js
@@ -0,0 +1,49 @@
+if(!dojo._hasResource["dojox.collections.tests.Stack"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.tests.Stack"] = true;
+dojo.provide("dojox.collections.tests.Stack");
+dojo.require("dojox.collections.Stack");
+
+tests.register("dojox.collections.tests.Stack", [
+ function testCtor(t){
+ var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
+ t.assertEqual(4, s.count);
+ },
+ function testClear(t){
+ var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
+ s.clear();
+ t.assertEqual(0, s.count);
+ },
+ function testClone(t){
+ var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
+ var cloned=s.clone();
+ t.assertEqual(s.count, cloned.count);
+ t.assertEqual(s.toArray().join(), cloned.toArray().join());
+ },
+ function testContains(t){
+ var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
+ t.assertTrue(s.contains("bar"));
+ t.assertFalse(s.contains("faz"));
+ },
+ function testGetIterator(t){
+ var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
+ var itr=s.getIterator();
+ while(!itr.atEnd()){ itr.get(); }
+ t.assertEqual("bull", itr.element);
+ },
+ function testPeek(t){
+ var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
+ t.assertEqual("bull", s.peek());
+ },
+ function testPop(t){
+ var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
+ t.assertEqual("bull", s.pop());
+ t.assertEqual("test", s.pop());
+ },
+ function testPush(t){
+ var s=new dojox.collections.Stack(["foo","bar","test","bull"]);
+ s.push("bug");
+ t.assertEqual("bug", s.peek());
+ }
+]);
+
+}
diff --git a/includes/js/dojox/collections/tests/_base.js b/includes/js/dojox/collections/tests/_base.js
new file mode 100644
index 0000000..f58a82c
--- /dev/null
+++ b/includes/js/dojox/collections/tests/_base.js
@@ -0,0 +1,84 @@
+if(!dojo._hasResource["dojox.collections.tests._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.tests._base"] = true;
+dojo.provide("dojox.collections.tests._base");
+dojo.require("dojox.collections");
+
+tests.register("dojox.collections.tests._base", [
+ function testDictionaryEntry(t){
+ var d=new dojox.collections.DictionaryEntry("foo","bar");
+ t.assertEqual("bar", d.valueOf());
+ t.assertEqual("bar", d.toString());
+ },
+
+ function testIterator(t){
+ var itr=new dojox.collections.Iterator(["foo","bar","baz","zoo"]);
+ t.assertEqual("foo", itr.element); // test initialization
+ t.assertTrue(!itr.atEnd());
+ t.assertEqual("foo", itr.get()); // make sure the first get doesn't advance.
+ t.assertEqual("bar", itr.get());
+ t.assertEqual("baz", itr.get());
+ t.assertEqual("zoo", itr.get());
+ t.assertTrue(itr.atEnd());
+ t.assertEqual(null, itr.get());
+
+ itr.reset();
+ t.assertTrue(!itr.atEnd());
+ t.assertEqual("foo", itr.element);
+
+ // test map
+ var a=itr.map(function(elm){
+ return elm+"-mapped";
+ });
+ itr=new dojox.collections.Iterator(a);
+ t.assertEqual("foo-mapped", itr.element); // test initialization
+ t.assertTrue(!itr.atEnd());
+ t.assertEqual("foo-mapped", itr.get()); // make sure the first get doesn't advance.
+ t.assertEqual("bar-mapped", itr.get());
+ t.assertEqual("baz-mapped", itr.get());
+ t.assertEqual("zoo-mapped", itr.get());
+ t.assertTrue(itr.atEnd());
+ t.assertEqual(null, itr.get());
+ },
+
+ function testDictionaryIterator(t){
+ /*
+ in the context of any of the Dictionary-based collections, the
+ element would normally return a DictionaryEntry. However, since
+ the DictionaryIterator is really an iterator of pure objects,
+ we will just test with an object here. This means all property
+ names are lost in the translation, but...that's why there's a
+ DictionaryEntry object :)
+ */
+ var itr=new dojox.collections.DictionaryIterator({
+ first:"foo", second:"bar", third:"baz", fourth:"zoo"
+ });
+ t.assertEqual("foo", itr.element); // test initialization
+ t.assertTrue(!itr.atEnd());
+ t.assertEqual("foo", itr.get()); // make sure the first get doesn't advance.
+ t.assertEqual("bar", itr.get());
+ t.assertEqual("baz", itr.get());
+ t.assertEqual("zoo", itr.get());
+ t.assertTrue(itr.atEnd());
+ t.assertEqual(null, itr.get());
+
+ itr.reset();
+ t.assertTrue(!itr.atEnd());
+ t.assertEqual("foo", itr.element);
+
+ // test map
+ var a=itr.map(function(elm){
+ return elm+"-mapped";
+ });
+ itr=new dojox.collections.Iterator(a);
+ t.assertEqual("foo-mapped", itr.element); // test initialization
+ t.assertTrue(!itr.atEnd());
+ t.assertEqual("foo-mapped", itr.get()); // make sure the first get doesn't advance.
+ t.assertEqual("bar-mapped", itr.get());
+ t.assertEqual("baz-mapped", itr.get());
+ t.assertEqual("zoo-mapped", itr.get());
+ t.assertTrue(itr.atEnd());
+ t.assertEqual(null, itr.get());
+ }
+]);
+
+}
diff --git a/includes/js/dojox/collections/tests/collections.js b/includes/js/dojox/collections/tests/collections.js
new file mode 100644
index 0000000..4fb2634
--- /dev/null
+++ b/includes/js/dojox/collections/tests/collections.js
@@ -0,0 +1,19 @@
+if(!dojo._hasResource["dojox.collections.tests.collections"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.collections.tests.collections"] = true;
+dojo.provide("dojox.collections.tests.collections");
+dojo.require("dojox.collections");
+
+try{
+ dojo.require("dojox.collections.tests._base");
+ dojo.require("dojox.collections.tests.ArrayList");
+ dojo.require("dojox.collections.tests.BinaryTree");
+ dojo.require("dojox.collections.tests.Dictionary");
+ dojo.require("dojox.collections.tests.Queue");
+ dojo.require("dojox.collections.tests.Set");
+ dojo.require("dojox.collections.tests.SortedList");
+ dojo.require("dojox.collections.tests.Stack");
+}catch(e){
+ doh.debug(e);
+}
+
+}
diff --git a/includes/js/dojox/collections/tests/runTests.html b/includes/js/dojox/collections/tests/runTests.html
new file mode 100644
index 0000000..37f26a6
--- /dev/null
+++ b/includes/js/dojox/collections/tests/runTests.html
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <title>Dojox.wire Unit Test Runner</title>
+ <meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.collections.tests.collections"></HEAD>
+ <BODY>
+ Redirecting to D.O.H runner.
+ </BODY>
+</HTML>