- <div id="method-Ext.util.MixedCollection-addAll"></div>/**
- * Adds all elements of an Array or an Object to the collection.
- * @param {Object/Array} objs An Object containing properties which will be added
- * to the collection, or an Array of values, each of which are added to the collection.
- * Functions references will be added to the collection if <code>{@link #allowFunctions}</code>
- * has been set to <tt>true</tt>.
- */
- addAll : function(objs){
- if(arguments.length > 1 || Ext.isArray(objs)){
- var args = arguments.length > 1 ? arguments : objs;
- for(var i = 0, len = args.length; i < len; i++){
- this.add(args[i]);
- }
- }else{
- for(var key in objs){
- if(this.allowFunctions || typeof objs[key] != 'function'){
- this.add(key, objs[key]);
- }
- }
- }
- },
-
- <div id="method-Ext.util.MixedCollection-each"></div>/**
- * Executes the specified function once for every item in the collection, passing the following arguments:
- * <div class="mdetail-params"><ul>
- * <li><b>item</b> : Mixed<p class="sub-desc">The collection item</p></li>
- * <li><b>index</b> : Number<p class="sub-desc">The item's index</p></li>
- * <li><b>length</b> : Number<p class="sub-desc">The total number of items in the collection</p></li>
- * </ul></div>
- * The function should return a boolean value. Returning false from the function will stop the iteration.
- * @param {Function} fn The function to execute for each item.
- * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function is executed. Defaults to the current item in the iteration.
- */
- each : function(fn, scope){
- var items = [].concat(this.items); // each safe for removal
- for(var i = 0, len = items.length; i < len; i++){
- if(fn.call(scope || items[i], items[i], i, len) === false){
- break;
- }
- }
- },
-
- <div id="method-Ext.util.MixedCollection-eachKey"></div>/**
- * Executes the specified function once for every key in the collection, passing each
- * key, and its associated item as the first two parameters.
- * @param {Function} fn The function to execute for each item.
- * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function is executed. Defaults to the browser window.
- */
- eachKey : function(fn, scope){
- for(var i = 0, len = this.keys.length; i < len; i++){
- fn.call(scope || window, this.keys[i], this.items[i], i, len);
- }
- },
-
- <div id="method-Ext.util.MixedCollection-find"></div>/**
- * Returns the first item in the collection which elicits a true return value from the
- * passed selection function.
- * @param {Function} fn The selection function to execute for each item.
- * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function is executed. Defaults to the browser window.
- * @return {Object} The first item in the collection which returned true from the selection function.
- */
- find : function(fn, scope){
- for(var i = 0, len = this.items.length; i < len; i++){
- if(fn.call(scope || window, this.items[i], this.keys[i])){
- return this.items[i];
- }
- }
- return null;
- },
-
- <div id="method-Ext.util.MixedCollection-insert"></div>/**
- * Inserts an item at the specified index in the collection. Fires the {@link #add} event when complete.
- * @param {Number} index The index to insert the item at.
- * @param {String} key The key to associate with the new item, or the item itself.
- * @param {Object} o (optional) If the second parameter was a key, the new item.
- * @return {Object} The item inserted.
- */
- insert : function(index, key, o){
- if(arguments.length == 2){
- o = arguments[1];
- key = this.getKey(o);
- }
- if(this.containsKey(key)){
- this.suspendEvents();
- this.removeKey(key);
- this.resumeEvents();
- }
- if(index >= this.length){
- return this.add(key, o);
- }
- this.length++;
- this.items.splice(index, 0, o);
- if(typeof key != 'undefined' && key !== null){
- this.map[key] = o;
- }
- this.keys.splice(index, 0, key);
- this.fireEvent('add', index, o, key);
- return o;
- },
-
- <div id="method-Ext.util.MixedCollection-remove"></div>/**
- * Remove an item from the collection.
- * @param {Object} o The item to remove.
- * @return {Object} The item removed or false if no item was removed.
- */
- remove : function(o){
- return this.removeAt(this.indexOf(o));
- },
-
- <div id="method-Ext.util.MixedCollection-removeAt"></div>/**
- * Remove an item from a specified index in the collection. Fires the {@link #remove} event when complete.
- * @param {Number} index The index within the collection of the item to remove.
- * @return {Object} The item removed or false if no item was removed.
- */
- removeAt : function(index){
- if(index < this.length && index >= 0){
- this.length--;
- var o = this.items[index];
- this.items.splice(index, 1);
- var key = this.keys[index];
- if(typeof key != 'undefined'){
- delete this.map[key];
- }
- this.keys.splice(index, 1);
- this.fireEvent('remove', o, key);
- return o;
- }
- return false;
- },
-
- <div id="method-Ext.util.MixedCollection-removeKey"></div>/**
- * Removed an item associated with the passed key fom the collection.
- * @param {String} key The key of the item to remove.
- * @return {Object} The item removed or false if no item was removed.
- */
- removeKey : function(key){
- return this.removeAt(this.indexOfKey(key));
- },
-
- <div id="method-Ext.util.MixedCollection-getCount"></div>/**
- * Returns the number of items in the collection.
- * @return {Number} the number of items in the collection.
- */
- getCount : function(){
- return this.length;
- },
-
- <div id="method-Ext.util.MixedCollection-indexOf"></div>/**
- * Returns index within the collection of the passed Object.
- * @param {Object} o The item to find the index of.
- * @return {Number} index of the item. Returns -1 if not found.
- */
- indexOf : function(o){
- return this.items.indexOf(o);
- },
-
- <div id="method-Ext.util.MixedCollection-indexOfKey"></div>/**
- * Returns index within the collection of the passed key.
- * @param {String} key The key to find the index of.
- * @return {Number} index of the key.
- */
- indexOfKey : function(key){
- return this.keys.indexOf(key);
- },
-
- <div id="method-Ext.util.MixedCollection-item"></div>/**
- * Returns the item associated with the passed key OR index.
- * Key has priority over index. This is the equivalent
- * of calling {@link #key} first, then if nothing matched calling {@link #itemAt}.
- * @param {String/Number} key The key or index of the item.
- * @return {Object} If the item is found, returns the item. If the item was not found, returns <tt>undefined</tt>.
- * If an item was found, but is a Class, returns <tt>null</tt>.
- */
- item : function(key){
- var mk = this.map[key],
- item = mk !== undefined ? mk : (typeof key == 'number') ? this.items[key] : undefined;
- return typeof item != 'function' || this.allowFunctions ? item : null; // for prototype!
- },
-
- <div id="method-Ext.util.MixedCollection-itemAt"></div>/**
- * Returns the item at the specified index.
- * @param {Number} index The index of the item.
- * @return {Object} The item at the specified index.
- */
- itemAt : function(index){
- return this.items[index];
- },
-
- <div id="method-Ext.util.MixedCollection-key"></div>/**
- * Returns the item associated with the passed key.
- * @param {String/Number} key The key of the item.
- * @return {Object} The item associated with the passed key.
- */
- key : function(key){
- return this.map[key];
- },
-
- <div id="method-Ext.util.MixedCollection-contains"></div>/**
- * Returns true if the collection contains the passed Object as an item.
- * @param {Object} o The Object to look for in the collection.
- * @return {Boolean} True if the collection contains the Object as an item.
- */
- contains : function(o){
- return this.indexOf(o) != -1;
- },
-
- <div id="method-Ext.util.MixedCollection-containsKey"></div>/**
- * Returns true if the collection contains the passed Object as a key.
- * @param {String} key The key to look for in the collection.
- * @return {Boolean} True if the collection contains the Object as a key.
- */
- containsKey : function(key){
- return typeof this.map[key] != 'undefined';
- },
-
- <div id="method-Ext.util.MixedCollection-clear"></div>/**
- * Removes all items from the collection. Fires the {@link #clear} event when complete.
- */
- clear : function(){
- this.length = 0;
- this.items = [];
- this.keys = [];
- this.map = {};
- this.fireEvent('clear');
- },
-
- <div id="method-Ext.util.MixedCollection-first"></div>/**
- * Returns the first item in the collection.
- * @return {Object} the first item in the collection..
- */
- first : function(){
- return this.items[0];
- },
-
- <div id="method-Ext.util.MixedCollection-last"></div>/**
- * Returns the last item in the collection.
- * @return {Object} the last item in the collection..
- */
- last : function(){
- return this.items[this.length-1];
- },
-
- /**
- * @private