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