A Collection class that maintains both numeric indexes and keys and exposes events.
This class has no public properties.
|
MixedCollection(Boolean allowFunctions ) |
MixedCollection |
|
|
add(String key , Object o ) : Object |
MixedCollection |
Adds an item to the collection. |
|
addAll(Object/Array objs ) : void |
MixedCollection |
Adds all elements of an Array or an Object to the collection. |
|
clear() : void |
MixedCollection |
Removes all items from the collection. |
|
contains(Object o ) : Boolean |
MixedCollection |
Returns true if the collection contains the passed Object as an item. |
|
containsKey(String key ) : Boolean |
MixedCollection |
Returns true if the collection contains the passed Object as a key. |
|
each(Function fn , [Object scope ]) : void |
MixedCollection |
Executes the specified function once for every item in the collection, passing each
item as the first and only parame... |
|
eachKey(Function fn , [Object scope ]) : void |
MixedCollection |
Executes the specified function once for every key in the collection, passing each
key, and its associated item as th... |
|
find(Function fn , [Object scope ]) : Object |
MixedCollection |
Returns the first item in the collection which elicits a true return value from the
passed selection function. |
|
first() : Object |
MixedCollection |
Returns the first item in the collection. |
|
get(String/Number key ) : Object |
MixedCollection |
Returns the item associated with the passed key or index. |
|
getCount() : Number |
MixedCollection |
Returns the number of items in the collection. |
|
getKey(o {Object} ) : Object |
MixedCollection |
MixedCollection has a generic way to fetch keys if you implement getKey.
// normal way
var mc = new Y... |
|
indexOf(Object o ) : Number |
MixedCollection |
Returns index within the collection of the passed Object. |
|
indexOfKey(String key ) : Number |
MixedCollection |
Returns index within the collection of the passed key. |
|
insert(Number index , String key , [Object o ]) : Object |
MixedCollection |
Inserts an item at the specified index in the collection. |
|
item(String/Number key ) : Object |
MixedCollection |
Returns the item associated with the passed key. |
|
last() : Object |
MixedCollection |
Returns the last item in the collection. |
|
remove(Object o ) : Object |
MixedCollection |
Removed an item from the collection. |
|
removeAt(Number index ) : void |
MixedCollection |
Remove an item from a specified index in the collection. |
|
removeKey(String key ) : void |
MixedCollection |
Removed an item associated with the passed key fom the collection. |
|
replace(String key , [o {Object} ]) : Object |
MixedCollection |
Replaces an item in the collection. |
|
add : (Number index , Object o , String key ) |
MixedCollection |
Fires when an item is added to the collection. |
|
clear : () |
MixedCollection |
Fires when the collection is cleared. |
|
remove : (Object o , [String key ]) |
MixedCollection |
Fires when an item is removed from the collection. |
|
replace : (String key , Object old , Object new ) |
MixedCollection |
Fires when an item is replaced in the collection. |
add
public function add(String key
, Object o
)
Adds an item to the collection.
This method is defined by MixedCollection.
addAll
public function addAll(Object/Array objs
)
Adds all elements of an Array or an Object to the collection.
This method is defined by MixedCollection.
clear
public function clear()
Removes all items from the collection.
This method is defined by MixedCollection.
contains
public function contains(Object o
)
Returns true if the collection contains the passed Object as an item.
This method is defined by MixedCollection.
containsKey
public function containsKey(String key
)
Returns true if the collection contains the passed Object as a key.
This method is defined by MixedCollection.
each
public function each(Function fn
, [Object scope
])
Executes the specified function once for every item in the collection, passing each
item as the first and only parameter.
This method is defined by MixedCollection.
eachKey
public function eachKey(Function fn
, [Object scope
])
Executes the specified function once for every key in the collection, passing each
key, and its associated item as the first two parameters.
This method is defined by MixedCollection.
find
public function find(Function fn
, [Object scope
])
Returns the first item in the collection which elicits a true return value from the
passed selection function.
This method is defined by MixedCollection.
first
public function first()
Returns the first item in the collection.
This method is defined by MixedCollection.
get
public function get(String/Number key
)
Returns the item associated with the passed key or index.
This method is defined by MixedCollection.
getCount
public function getCount()
Returns the number of items in the collection.
This method is defined by MixedCollection.
getKey
public function getKey(o {Object}
)
MixedCollection has a generic way to fetch keys if you implement getKey.
// normal way
var mc = new YAHOO.ext.util.MixedCollection();
mc.add(someEl.dom.id, someEl);
mc.add(otherEl.dom.id, otherEl);
//and so on
// using getKey
var mc = new YAHOO.ext.util.MixedCollection();
mc.getKey = function(el){
return el.dom.id;
}
mc.add(someEl);
mc.add(otherEl);
// etc
This method is defined by MixedCollection.
indexOf
public function indexOf(Object o
)
Returns index within the collection of the passed Object.
This method is defined by MixedCollection.
indexOfKey
public function indexOfKey(String key
)
Returns index within the collection of the passed key.
This method is defined by MixedCollection.
insert
public function insert(Number index
, String key
, [Object o
])
Inserts an item at the specified index in the collection.
Parameters:
index
: NumberThe index to insert the item at.
key
: StringThe key to associate with the new item, or the item itself.
o
: Object(optional) If the second parameter was a key, the new item.
Returns:
This method is defined by MixedCollection.
item
public function item(String/Number key
)
Returns the item associated with the passed key.
This method is defined by MixedCollection.
last
public function last()
Returns the last item in the collection.
This method is defined by MixedCollection.
remove
public function remove(Object o
)
Removed an item from the collection.
Parameters:
o
: ObjectThe item to remove.
Returns:
This method is defined by MixedCollection.
removeAt
public function removeAt(Number index
)
Remove an item from a specified index in the collection.
This method is defined by MixedCollection.
removeKey
public function removeKey(String key
)
Removed an item associated with the passed key fom the collection.
This method is defined by MixedCollection.
replace
public function replace(String key
, [o {Object}
])
Replaces an item in the collection.
Parameters:
key
: StringThe key associated with the item to replace, or the item to replace.
{Object}
: oo (optional) If the first parameter passed was a key, the item to associate with that key.
Returns:
This method is defined by MixedCollection.