Upgrade to ExtJS 3.0.3 - Released 10/11/2009
[extjs.git] / docs / source / MixedCollection.html
1 <html>
2 <head>
3   <title>The source code</title>
4     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
6 </head>
7 <body  onload="prettyPrint();">
8     <pre class="prettyprint lang-js">/*!
9  * Ext JS Library 3.0.3
10  * Copyright(c) 2006-2009 Ext JS, LLC
11  * licensing@extjs.com
12  * http://www.extjs.com/license
13  */
14 <div id="cls-Ext.util.MixedCollection"></div>/**\r
15  * @class Ext.util.MixedCollection\r
16  * @extends Ext.util.Observable\r
17  * A Collection class that maintains both numeric indexes and keys and exposes events.\r
18  * @constructor\r
19  * @param {Boolean} allowFunctions Specify <tt>true</tt> if the {@link #addAll}\r
20  * function should add function references to the collection. Defaults to\r
21  * <tt>false</tt>.\r
22  * @param {Function} keyFn A function that can accept an item of the type(s) stored in this MixedCollection\r
23  * and return the key value for that item.  This is used when available to look up the key on items that\r
24  * were passed without an explicit key parameter to a MixedCollection method.  Passing this parameter is\r
25  * equivalent to providing an implementation for the {@link #getKey} method.\r
26  */\r
27 Ext.util.MixedCollection = function(allowFunctions, keyFn){\r
28     this.items = [];\r
29     this.map = {};\r
30     this.keys = [];\r
31     this.length = 0;\r
32     this.addEvents(\r
33         <div id="event-Ext.util.MixedCollection-clear"></div>/**\r
34          * @event clear\r
35          * Fires when the collection is cleared.\r
36          */\r
37         'clear',\r
38         <div id="event-Ext.util.MixedCollection-add"></div>/**\r
39          * @event add\r
40          * Fires when an item is added to the collection.\r
41          * @param {Number} index The index at which the item was added.\r
42          * @param {Object} o The item added.\r
43          * @param {String} key The key associated with the added item.\r
44          */\r
45         'add',\r
46         <div id="event-Ext.util.MixedCollection-replace"></div>/**\r
47          * @event replace\r
48          * Fires when an item is replaced in the collection.\r
49          * @param {String} key he key associated with the new added.\r
50          * @param {Object} old The item being replaced.\r
51          * @param {Object} new The new item.\r
52          */\r
53         'replace',\r
54         <div id="event-Ext.util.MixedCollection-remove"></div>/**\r
55          * @event remove\r
56          * Fires when an item is removed from the collection.\r
57          * @param {Object} o The item being removed.\r
58          * @param {String} key (optional) The key associated with the removed item.\r
59          */\r
60         'remove',\r
61         'sort'\r
62     );\r
63     this.allowFunctions = allowFunctions === true;\r
64     if(keyFn){\r
65         this.getKey = keyFn;\r
66     }\r
67     Ext.util.MixedCollection.superclass.constructor.call(this);\r
68 };\r
69 \r
70 Ext.extend(Ext.util.MixedCollection, Ext.util.Observable, {\r
71 \r
72     <div id="cfg-Ext.util.MixedCollection-allowFunctions"></div>/**\r
73      * @cfg {Boolean} allowFunctions Specify <tt>true</tt> if the {@link #addAll}\r
74      * function should add function references to the collection. Defaults to\r
75      * <tt>false</tt>.\r
76      */\r
77     allowFunctions : false,\r
78 \r
79     <div id="method-Ext.util.MixedCollection-add"></div>/**\r
80      * Adds an item to the collection. Fires the {@link #add} event when complete.\r
81      * @param {String} key <p>The key to associate with the item, or the new item.</p>\r
82      * <p>If a {@link #getKey} implementation was specified for this MixedCollection,\r
83      * or if the key of the stored items is in a property called <tt><b>id</b></tt>,\r
84      * the MixedCollection will be able to <i>derive</i> the key for the new item.\r
85      * In this case just pass the new item in this parameter.</p>\r
86      * @param {Object} o The item to add.\r
87      * @return {Object} The item added.\r
88      */\r
89     add : function(key, o){\r
90         if(arguments.length == 1){\r
91             o = arguments[0];\r
92             key = this.getKey(o);\r
93         }\r
94         if(typeof key != 'undefined' && key !== null){\r
95             var old = this.map[key];\r
96             if(typeof old != 'undefined'){\r
97                 return this.replace(key, o);\r
98             }\r
99             this.map[key] = o;\r
100         }\r
101         this.length++;\r
102         this.items.push(o);\r
103         this.keys.push(key);\r
104         this.fireEvent('add', this.length-1, o, key);\r
105         return o;\r
106     },\r
107 \r
108     <div id="method-Ext.util.MixedCollection-getKey"></div>/**\r
109       * MixedCollection has a generic way to fetch keys if you implement getKey.  The default implementation\r
110       * simply returns <b><code>item.id</code></b> but you can provide your own implementation\r
111       * to return a different value as in the following examples:<pre><code>\r
112 // normal way\r
113 var mc = new Ext.util.MixedCollection();\r
114 mc.add(someEl.dom.id, someEl);\r
115 mc.add(otherEl.dom.id, otherEl);\r
116 //and so on\r
117 \r
118 // using getKey\r
119 var mc = new Ext.util.MixedCollection();\r
120 mc.getKey = function(el){\r
121    return el.dom.id;\r
122 };\r
123 mc.add(someEl);\r
124 mc.add(otherEl);\r
125 \r
126 // or via the constructor\r
127 var mc = new Ext.util.MixedCollection(false, function(el){\r
128    return el.dom.id;\r
129 });\r
130 mc.add(someEl);\r
131 mc.add(otherEl);\r
132      * </code></pre>\r
133      * @param {Object} item The item for which to find the key.\r
134      * @return {Object} The key for the passed item.\r
135      */\r
136     getKey : function(o){\r
137          return o.id;\r
138     },\r
139 \r
140     <div id="method-Ext.util.MixedCollection-replace"></div>/**\r
141      * Replaces an item in the collection. Fires the {@link #replace} event when complete.\r
142      * @param {String} key <p>The key associated with the item to replace, or the replacement item.</p>\r
143      * <p>If you supplied a {@link #getKey} implementation for this MixedCollection, or if the key\r
144      * of your stored items is in a property called <tt><b>id</b></tt>, then the MixedCollection\r
145      * will be able to <i>derive</i> the key of the replacement item. If you want to replace an item\r
146      * with one having the same key value, then just pass the replacement item in this parameter.</p>\r
147      * @param o {Object} o (optional) If the first parameter passed was a key, the item to associate\r
148      * with that key.\r
149      * @return {Object}  The new item.\r
150      */\r
151     replace : function(key, o){\r
152         if(arguments.length == 1){\r
153             o = arguments[0];\r
154             key = this.getKey(o);\r
155         }\r
156         var old = this.map[key];\r
157         if(typeof key == 'undefined' || key === null || typeof old == 'undefined'){\r
158              return this.add(key, o);\r
159         }\r
160         var index = this.indexOfKey(key);\r
161         this.items[index] = o;\r
162         this.map[key] = o;\r
163         this.fireEvent('replace', key, old, o);\r
164         return o;\r
165     },\r
166 \r
167     <div id="method-Ext.util.MixedCollection-addAll"></div>/**\r
168      * Adds all elements of an Array or an Object to the collection.\r
169      * @param {Object/Array} objs An Object containing properties which will be added\r
170      * to the collection, or an Array of values, each of which are added to the collection.\r
171      * Functions references will be added to the collection if <code>{@link #allowFunctions}</code>\r
172      * has been set to <tt>true</tt>.\r
173      */\r
174     addAll : function(objs){\r
175         if(arguments.length > 1 || Ext.isArray(objs)){\r
176             var args = arguments.length > 1 ? arguments : objs;\r
177             for(var i = 0, len = args.length; i < len; i++){\r
178                 this.add(args[i]);\r
179             }\r
180         }else{\r
181             for(var key in objs){\r
182                 if(this.allowFunctions || typeof objs[key] != 'function'){\r
183                     this.add(key, objs[key]);\r
184                 }\r
185             }\r
186         }\r
187     },\r
188 \r
189     <div id="method-Ext.util.MixedCollection-each"></div>/**\r
190      * Executes the specified function once for every item in the collection, passing the following arguments:\r
191      * <div class="mdetail-params"><ul>\r
192      * <li><b>item</b> : Mixed<p class="sub-desc">The collection item</p></li>\r
193      * <li><b>index</b> : Number<p class="sub-desc">The item's index</p></li>\r
194      * <li><b>length</b> : Number<p class="sub-desc">The total number of items in the collection</p></li>\r
195      * </ul></div>\r
196      * The function should return a boolean value. Returning false from the function will stop the iteration.\r
197      * @param {Function} fn The function to execute for each item.\r
198      * @param {Object} scope (optional) The scope in which to execute the function.\r
199      */\r
200     each : function(fn, scope){\r
201         var items = [].concat(this.items); // each safe for removal\r
202         for(var i = 0, len = items.length; i < len; i++){\r
203             if(fn.call(scope || items[i], items[i], i, len) === false){\r
204                 break;\r
205             }\r
206         }\r
207     },\r
208 \r
209     <div id="method-Ext.util.MixedCollection-eachKey"></div>/**\r
210      * Executes the specified function once for every key in the collection, passing each\r
211      * key, and its associated item as the first two parameters.\r
212      * @param {Function} fn The function to execute for each item.\r
213      * @param {Object} scope (optional) The scope in which to execute the function.\r
214      */\r
215     eachKey : function(fn, scope){\r
216         for(var i = 0, len = this.keys.length; i < len; i++){\r
217             fn.call(scope || window, this.keys[i], this.items[i], i, len);\r
218         }\r
219     },\r
220 \r
221     <div id="method-Ext.util.MixedCollection-find"></div>/**\r
222      * Returns the first item in the collection which elicits a true return value from the\r
223      * passed selection function.\r
224      * @param {Function} fn The selection function to execute for each item.\r
225      * @param {Object} scope (optional) The scope in which to execute the function.\r
226      * @return {Object} The first item in the collection which returned true from the selection function.\r
227      */\r
228     find : function(fn, scope){\r
229         for(var i = 0, len = this.items.length; i < len; i++){\r
230             if(fn.call(scope || window, this.items[i], this.keys[i])){\r
231                 return this.items[i];\r
232             }\r
233         }\r
234         return null;\r
235     },\r
236 \r
237     <div id="method-Ext.util.MixedCollection-insert"></div>/**\r
238      * Inserts an item at the specified index in the collection. Fires the {@link #add} event when complete.\r
239      * @param {Number} index The index to insert the item at.\r
240      * @param {String} key The key to associate with the new item, or the item itself.\r
241      * @param {Object} o (optional) If the second parameter was a key, the new item.\r
242      * @return {Object} The item inserted.\r
243      */\r
244     insert : function(index, key, o){\r
245         if(arguments.length == 2){\r
246             o = arguments[1];\r
247             key = this.getKey(o);\r
248         }\r
249         if(this.containsKey(key)){\r
250             this.suspendEvents();\r
251             this.removeKey(key);\r
252             this.resumeEvents();\r
253         }\r
254         if(index >= this.length){\r
255             return this.add(key, o);\r
256         }\r
257         this.length++;\r
258         this.items.splice(index, 0, o);\r
259         if(typeof key != 'undefined' && key !== null){\r
260             this.map[key] = o;\r
261         }\r
262         this.keys.splice(index, 0, key);\r
263         this.fireEvent('add', index, o, key);\r
264         return o;\r
265     },\r
266 \r
267     <div id="method-Ext.util.MixedCollection-remove"></div>/**\r
268      * Remove an item from the collection.\r
269      * @param {Object} o The item to remove.\r
270      * @return {Object} The item removed or false if no item was removed.\r
271      */\r
272     remove : function(o){\r
273         return this.removeAt(this.indexOf(o));\r
274     },\r
275 \r
276     <div id="method-Ext.util.MixedCollection-removeAt"></div>/**\r
277      * Remove an item from a specified index in the collection. Fires the {@link #remove} event when complete.\r
278      * @param {Number} index The index within the collection of the item to remove.\r
279      * @return {Object} The item removed or false if no item was removed.\r
280      */\r
281     removeAt : function(index){\r
282         if(index < this.length && index >= 0){\r
283             this.length--;\r
284             var o = this.items[index];\r
285             this.items.splice(index, 1);\r
286             var key = this.keys[index];\r
287             if(typeof key != 'undefined'){\r
288                 delete this.map[key];\r
289             }\r
290             this.keys.splice(index, 1);\r
291             this.fireEvent('remove', o, key);\r
292             return o;\r
293         }\r
294         return false;\r
295     },\r
296 \r
297     <div id="method-Ext.util.MixedCollection-removeKey"></div>/**\r
298      * Removed an item associated with the passed key fom the collection.\r
299      * @param {String} key The key of the item to remove.\r
300      * @return {Object} The item removed or false if no item was removed.\r
301      */\r
302     removeKey : function(key){\r
303         return this.removeAt(this.indexOfKey(key));\r
304     },\r
305 \r
306     <div id="method-Ext.util.MixedCollection-getCount"></div>/**\r
307      * Returns the number of items in the collection.\r
308      * @return {Number} the number of items in the collection.\r
309      */\r
310     getCount : function(){\r
311         return this.length;\r
312     },\r
313     \r
314     <div id="method-Ext.util.MixedCollection-indexOf"></div>/**\r
315      * Returns index within the collection of the passed Object.\r
316      * @param {Object} o The item to find the index of.\r
317      * @return {Number} index of the item. Returns -1 if not found.\r
318      */\r
319     indexOf : function(o){\r
320         return this.items.indexOf(o);\r
321     },\r
322 \r
323     <div id="method-Ext.util.MixedCollection-indexOfKey"></div>/**\r
324      * Returns index within the collection of the passed key.\r
325      * @param {String} key The key to find the index of.\r
326      * @return {Number} index of the key.\r
327      */\r
328     indexOfKey : function(key){\r
329         return this.keys.indexOf(key);\r
330     },\r
331 \r
332     <div id="method-Ext.util.MixedCollection-item"></div>/**\r
333      * Returns the item associated with the passed key OR index.\r
334      * Key has priority over index.  This is the equivalent\r
335      * of calling {@link #key} first, then if nothing matched calling {@link #itemAt}.\r
336      * @param {String/Number} key The key or index of the item.\r
337      * @return {Object} If the item is found, returns the item.  If the item was not found, returns <tt>undefined</tt>.\r
338      * If an item was found, but is a Class, returns <tt>null</tt>.\r
339      */\r
340     item : function(key){\r
341         var mk = this.map[key],\r
342             item = mk !== undefined ? mk : (typeof key == 'number') ? this.items[key] : undefined;\r
343         return !Ext.isFunction(item) || this.allowFunctions ? item : null; // for prototype!\r
344     },\r
345 \r
346     <div id="method-Ext.util.MixedCollection-itemAt"></div>/**\r
347      * Returns the item at the specified index.\r
348      * @param {Number} index The index of the item.\r
349      * @return {Object} The item at the specified index.\r
350      */\r
351     itemAt : function(index){\r
352         return this.items[index];\r
353     },\r
354 \r
355     <div id="method-Ext.util.MixedCollection-key"></div>/**\r
356      * Returns the item associated with the passed key.\r
357      * @param {String/Number} key The key of the item.\r
358      * @return {Object} The item associated with the passed key.\r
359      */\r
360     key : function(key){\r
361         return this.map[key];\r
362     },\r
363 \r
364     <div id="method-Ext.util.MixedCollection-contains"></div>/**\r
365      * Returns true if the collection contains the passed Object as an item.\r
366      * @param {Object} o  The Object to look for in the collection.\r
367      * @return {Boolean} True if the collection contains the Object as an item.\r
368      */\r
369     contains : function(o){\r
370         return this.indexOf(o) != -1;\r
371     },\r
372 \r
373     <div id="method-Ext.util.MixedCollection-containsKey"></div>/**\r
374      * Returns true if the collection contains the passed Object as a key.\r
375      * @param {String} key The key to look for in the collection.\r
376      * @return {Boolean} True if the collection contains the Object as a key.\r
377      */\r
378     containsKey : function(key){\r
379         return typeof this.map[key] != 'undefined';\r
380     },\r
381 \r
382     <div id="method-Ext.util.MixedCollection-clear"></div>/**\r
383      * Removes all items from the collection.  Fires the {@link #clear} event when complete.\r
384      */\r
385     clear : function(){\r
386         this.length = 0;\r
387         this.items = [];\r
388         this.keys = [];\r
389         this.map = {};\r
390         this.fireEvent('clear');\r
391     },\r
392 \r
393     <div id="method-Ext.util.MixedCollection-first"></div>/**\r
394      * Returns the first item in the collection.\r
395      * @return {Object} the first item in the collection..\r
396      */\r
397     first : function(){\r
398         return this.items[0];\r
399     },\r
400 \r
401     <div id="method-Ext.util.MixedCollection-last"></div>/**\r
402      * Returns the last item in the collection.\r
403      * @return {Object} the last item in the collection..\r
404      */\r
405     last : function(){\r
406         return this.items[this.length-1];\r
407     },\r
408 \r
409     /**\r
410      * @private\r
411      * @param {String} property Property to sort by ('key', 'value', or 'index')\r
412      * @param {String} dir (optional) Direction to sort 'ASC' or 'DESC'. Defaults to 'ASC'.\r
413      * @param {Function} fn (optional) Comparison function that defines the sort order.\r
414      * Defaults to sorting by numeric value.  \r
415      */\r
416     _sort : function(property, dir, fn){\r
417         var i,\r
418             len,\r
419             dsc = String(dir).toUpperCase() == 'DESC' ? -1 : 1,\r
420             c = [], k = this.keys, items = this.items;\r
421             \r
422         fn = fn || function(a, b){\r
423             return a-b;\r
424         };\r
425         for(i = 0, len = items.length; i < len; i++){\r
426             c[c.length] = {key: k[i], value: items[i], index: i};\r
427         }\r
428         c.sort(function(a, b){\r
429             var v = fn(a[property], b[property]) * dsc;\r
430             if(v === 0){\r
431                 v = (a.index < b.index ? -1 : 1);\r
432             }\r
433             return v;\r
434         });\r
435         for(i = 0, len = c.length; i < len; i++){\r
436             items[i] = c[i].value;\r
437             k[i] = c[i].key;\r
438         }\r
439         this.fireEvent('sort', this);\r
440     },\r
441 \r
442     <div id="method-Ext.util.MixedCollection-sort"></div>/**\r
443      * Sorts this collection by <b>item</b> value with the passed comparison function.\r
444      * @param {String} direction (optional) 'ASC' or 'DESC'. Defaults to 'ASC'.\r
445      * @param {Function} fn (optional) Comparison function that defines the sort order.\r
446      * Defaults to sorting by numeric value.  \r
447      */\r
448     sort : function(dir, fn){\r
449         this._sort('value', dir, fn);\r
450     },\r
451 \r
452     <div id="method-Ext.util.MixedCollection-keySort"></div>/**\r
453      * Sorts this collection by <b>key</b>s.\r
454      * @param {String} direction (optional) 'ASC' or 'DESC'. Defaults to 'ASC'.\r
455      * @param {Function} fn (optional) Comparison function that defines the sort order.\r
456      * Defaults to sorting by case insensitive string.  \r
457      */\r
458     keySort : function(dir, fn){\r
459         this._sort('key', dir, fn || function(a, b){\r
460             var v1 = String(a).toUpperCase(), v2 = String(b).toUpperCase();\r
461             return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);\r
462         });\r
463     },\r
464 \r
465     <div id="method-Ext.util.MixedCollection-getRange"></div>/**\r
466      * Returns a range of items in this collection\r
467      * @param {Number} startIndex (optional) The starting index. Defaults to 0.\r
468      * @param {Number} endIndex (optional) The ending index. Defaults to the last item.\r
469      * @return {Array} An array of items\r
470      */\r
471     getRange : function(start, end){\r
472         var items = this.items;\r
473         if(items.length < 1){\r
474             return [];\r
475         }\r
476         start = start || 0;\r
477         end = Math.min(typeof end == 'undefined' ? this.length-1 : end, this.length-1);\r
478         var i, r = [];\r
479         if(start <= end){\r
480             for(i = start; i <= end; i++) {\r
481                 r[r.length] = items[i];\r
482             }\r
483         }else{\r
484             for(i = start; i >= end; i--) {\r
485                 r[r.length] = items[i];\r
486             }\r
487         }\r
488         return r;\r
489     },\r
490 \r
491     <div id="method-Ext.util.MixedCollection-filter"></div>/**\r
492      * Filter the <i>objects</i> in this collection by a specific property.\r
493      * Returns a new collection that has been filtered.\r
494      * @param {String} property A property on your objects\r
495      * @param {String/RegExp} value Either string that the property values\r
496      * should start with or a RegExp to test against the property\r
497      * @param {Boolean} anyMatch (optional) True to match any part of the string, not just the beginning\r
498      * @param {Boolean} caseSensitive (optional) True for case sensitive comparison (defaults to False).\r
499      * @return {MixedCollection} The new filtered collection\r
500      */\r
501     filter : function(property, value, anyMatch, caseSensitive){\r
502         if(Ext.isEmpty(value, false)){\r
503             return this.clone();\r
504         }\r
505         value = this.createValueMatcher(value, anyMatch, caseSensitive);\r
506         return this.filterBy(function(o){\r
507             return o && value.test(o[property]);\r
508         });\r
509     },\r
510 \r
511     <div id="method-Ext.util.MixedCollection-filterBy"></div>/**\r
512      * Filter by a function. Returns a <i>new</i> collection that has been filtered.\r
513      * The passed function will be called with each object in the collection.\r
514      * If the function returns true, the value is included otherwise it is filtered.\r
515      * @param {Function} fn The function to be called, it will receive the args o (the object), k (the key)\r
516      * @param {Object} scope (optional) The scope of the function (defaults to this)\r
517      * @return {MixedCollection} The new filtered collection\r
518      */\r
519     filterBy : function(fn, scope){\r
520         var r = new Ext.util.MixedCollection();\r
521         r.getKey = this.getKey;\r
522         var k = this.keys, it = this.items;\r
523         for(var i = 0, len = it.length; i < len; i++){\r
524             if(fn.call(scope||this, it[i], k[i])){\r
525                 r.add(k[i], it[i]);\r
526             }\r
527         }\r
528         return r;\r
529     },\r
530 \r
531     <div id="method-Ext.util.MixedCollection-findIndex"></div>/**\r
532      * Finds the index of the first matching object in this collection by a specific property/value.\r
533      * @param {String} property The name of a property on your objects.\r
534      * @param {String/RegExp} value A string that the property values\r
535      * should start with or a RegExp to test against the property.\r
536      * @param {Number} start (optional) The index to start searching at (defaults to 0).\r
537      * @param {Boolean} anyMatch (optional) True to match any part of the string, not just the beginning.\r
538      * @param {Boolean} caseSensitive (optional) True for case sensitive comparison.\r
539      * @return {Number} The matched index or -1\r
540      */\r
541     findIndex : function(property, value, start, anyMatch, caseSensitive){\r
542         if(Ext.isEmpty(value, false)){\r
543             return -1;\r
544         }\r
545         value = this.createValueMatcher(value, anyMatch, caseSensitive);\r
546         return this.findIndexBy(function(o){\r
547             return o && value.test(o[property]);\r
548         }, null, start);\r
549     },\r
550 \r
551     <div id="method-Ext.util.MixedCollection-findIndexBy"></div>/**\r
552      * Find the index of the first matching object in this collection by a function.\r
553      * If the function returns <i>true</i> it is considered a match.\r
554      * @param {Function} fn The function to be called, it will receive the args o (the object), k (the key).\r
555      * @param {Object} scope (optional) The scope of the function (defaults to this).\r
556      * @param {Number} start (optional) The index to start searching at (defaults to 0).\r
557      * @return {Number} The matched index or -1\r
558      */\r
559     findIndexBy : function(fn, scope, start){\r
560         var k = this.keys, it = this.items;\r
561         for(var i = (start||0), len = it.length; i < len; i++){\r
562             if(fn.call(scope||this, it[i], k[i])){\r
563                 return i;\r
564             }\r
565         }\r
566         return -1;\r
567     },\r
568 \r
569     // private\r
570     createValueMatcher : function(value, anyMatch, caseSensitive){\r
571         if(!value.exec){ // not a regex\r
572             value = String(value);\r
573             value = new RegExp((anyMatch === true ? '' : '^') + Ext.escapeRe(value), caseSensitive ? '' : 'i');\r
574         }\r
575         return value;\r
576     },\r
577 \r
578     <div id="method-Ext.util.MixedCollection-clone"></div>/**\r
579      * Creates a shallow copy of this collection\r
580      * @return {MixedCollection}\r
581      */\r
582     clone : function(){\r
583         var r = new Ext.util.MixedCollection();\r
584         var k = this.keys, it = this.items;\r
585         for(var i = 0, len = it.length; i < len; i++){\r
586             r.add(k[i], it[i]);\r
587         }\r
588         r.getKey = this.getKey;\r
589         return r;\r
590     }\r
591 });\r
592 <div id="method-Ext.util.MixedCollection-get"></div>/**\r
593  * This method calls {@link #item item()}.\r
594  * Returns the item associated with the passed key OR index. Key has priority\r
595  * over index.  This is the equivalent of calling {@link #key} first, then if\r
596  * nothing matched calling {@link #itemAt}.\r
597  * @param {String/Number} key The key or index of the item.\r
598  * @return {Object} If the item is found, returns the item.  If the item was\r
599  * not found, returns <tt>undefined</tt>. If an item was found, but is a Class,\r
600  * returns <tt>null</tt>.\r
601  */\r
602 Ext.util.MixedCollection.prototype.get = Ext.util.MixedCollection.prototype.item;</pre>
603 </body>
604 </html>