Debian Codegraph @

dojox/collections/Set.js

raw symbols SCIP
1 define(["./_base", "./ArrayList"], function(dxc, ArrayList){
2
3 dxc.Set=new (function(){
4 function conv(arr){
5 if(arr.constructor==Array){
6 return new ArrayList(arr); // dojox.collections.ArrayList
7 }
8 return arr; // dojox.collections.ArrayList
9 }
10 this.union = function(/*array*/ setA, /*array*/ setB){
11 // summary:
12 // Return the union of the two passed sets.
13 setA=conv(setA);
14 setB=conv(setB);
15 var result = new ArrayList(setA.toArray());
16 var e = setB.getIterator();
17 while(!e.atEnd()){
18 var item=e.get();
19 if(!result.contains(item)){
20 result.add(item);
21 }
22 }
23 return result; // dojox.collections.ArrayList
24 };
25 this.intersection = function(/*array*/ setA, /*array*/ setB){
26 // summary:
27 // Return the intersection of the two passed sets.
28 setA=conv(setA);
29 setB=conv(setB);
30 var result = new ArrayList();
31 var e = setB.getIterator();
32 while(!e.atEnd()){
33 var item=e.get();
34 if(setA.contains(item)){
35 result.add(item);
36 }
37 }
38 return result; // dojox.collections.ArrayList
39 };
40 this.difference = function(/*array*/ setA, /*array*/ setB){
41 // summary:
42 // Returns everything in setA that is not in setB.
43 setA=conv(setA);
44 setB=conv(setB);
45 var result = new ArrayList();
46 var e=setA.getIterator();
47 while(!e.atEnd()){
48 var item=e.get();
49 if(!setB.contains(item)){
50 result.add(item);
51 }
52 }
53 return result; // dojox.collections.ArrayList
54 };
55 this.isSubSet = function(/*array*/ setA, /*array*/ setB) {
56 // summary:
57 // Returns if set B is a subset of set A.
58 setA=conv(setA);
59 setB=conv(setB);
60 var e = setA.getIterator();
61 while(!e.atEnd()){
62 if(!setB.contains(e.get())){
63 return false; // boolean
64 }
65 }
66 return true; // boolean
67 };
68 this.isSuperSet = function(/*array*/ setA, /*array*/ setB){
69 // summary:
70 // Returns if set B is a superset of set A.
71 setA=conv(setA);
72 setB=conv(setB);
73 var e = setB.getIterator();
74 while(!e.atEnd()){
75 if(!setA.contains(e.get())){
76 return false; // boolean
77 }
78 }
79 return true; // boolean
80 };
81 })();
82 return dxc.Set;
83 });