Location: A review of cardiac cellular electrophysiology models @ f6a8f9030738 / dojo-presentation / js / dojo / dojox / collections / Set.js

Author:
David Nickerson <nickerso@users.sourceforge.net>
Date:
2009-07-16 02:00:03+12:00
Desc:
the starting point for the HH tutorial example
Permanent Source URI:
https://models.fieldml.org/workspace/a1/rawfile/f6a8f90307388eb4b040ee3566b84d88b59247f7/dojo-presentation/js/dojo/dojox/collections/Set.js

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
		};
	})();
})();