Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / collections / ArrayList.js

History | View | Annotate | Download (1.77 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.collections.ArrayList"]){
9
dojo._hasResource["dojox.collections.ArrayList"]=true;
10
dojo.provide("dojox.collections.ArrayList");
11
dojo.require("dojox.collections._base");
12
dojox.collections.ArrayList=function(_1){
13
var _2=[];
14
if(_1){
15
_2=_2.concat(_1);
16
}
17
this.count=_2.length;
18
this.add=function(_3){
19
_2.push(_3);
20
this.count=_2.length;
21
};
22
this.addRange=function(a){
23
if(a.getIterator){
24
var e=a.getIterator();
25
while(!e.atEnd()){
26
this.add(e.get());
27
}
28
this.count=_2.length;
29
}else{
30
for(var i=0;i<a.length;i++){
31
_2.push(a[i]);
32
}
33
this.count=_2.length;
34
}
35
};
36
this.clear=function(){
37
_2.splice(0,_2.length);
38
this.count=0;
39
};
40
this.clone=function(){
41
return new dojox.collections.ArrayList(_2);
42
};
43
this.contains=function(_4){
44
for(var i=0;i<_2.length;i++){
45
if(_2[i]==_4){
46
return true;
47
}
48
}
49
return false;
50
};
51
this.forEach=function(fn,_5){
52
dojo.forEach(_2,fn,_5);
53
};
54
this.getIterator=function(){
55
return new dojox.collections.Iterator(_2);
56
};
57
this.indexOf=function(_6){
58
for(var i=0;i<_2.length;i++){
59
if(_2[i]==_6){
60
return i;
61
}
62
}
63
return -1;
64
};
65
this.insert=function(i,_7){
66
_2.splice(i,0,_7);
67
this.count=_2.length;
68
};
69
this.item=function(i){
70
return _2[i];
71
};
72
this.remove=function(_8){
73
var i=this.indexOf(_8);
74
if(i>=0){
75
_2.splice(i,1);
76
}
77
this.count=_2.length;
78
};
79
this.removeAt=function(i){
80
_2.splice(i,1);
81
this.count=_2.length;
82
};
83
this.reverse=function(){
84
_2.reverse();
85
};
86
this.sort=function(fn){
87
if(fn){
88
_2.sort(fn);
89
}else{
90
_2.sort();
91
}
92
};
93
this.setByIndex=function(i,_9){
94
_2[i]=_9;
95
this.count=_2.length;
96
};
97
this.toArray=function(){
98
return [].concat(_2);
99
};
100
this.toString=function(_a){
101
return _2.join((_a||","));
102
};
103
};
104
}