<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>API: collection YUI~array~extras (YUI Library)</title>
<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css" />
<link rel="stylesheet" type="text/css" href="assets/api.css" />
<script type="text/javascript" src="assets/api-js"></script>
<script type="text/javascript" src="assets/ac-js"></script>
</head>
<body id="yahoo-com">
<div id="doc3" class="yui-t2">
<div id="hd">
<h1><a href="http://developer.yahoo.com/yui/" title="Yahoo! UI Library">Yahoo! UI Library</a></h1>
<h3>collection <span class="subtitle">3.0.0</span></h3>
<a href="./index.html" title="Yahoo! UI Library">Yahoo! UI Library</a>
> <a href="./module_collection.html" title="collection">collection</a>
> YUI~array~extras
<form onsubmit="return false">
<div id="propertysearch">
Search: <input autocomplete="off" id="searchinput" />
<div id="searchresults">
</div>
</div>
</form>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
<fieldset>
<legend>Filters</legend>
<span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
<span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
<span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
</fieldset>
</form>
<h2>
Class <b property="yui:name">YUI~array~extras</b>
<span class="extends">
</span>
</h2>
<!-- class tree goes here -->
<div class="summary description" property="yui:description">
Adds the following array utilities to the YUI instance
(Y.Array). This is in addition to the methods provided
in the core.
</div>
<div rel="yui:properties" resource="#properties">
<div class="section field details">
<h3 id="properties">Properties</h3>
<div class="content">
<div class="" rel="yui:property" resource="#property_lastIndexOf">
<h4><a name="property_lastIndexOf" property="yui:name">lastIndexOf</a>
- <code>static <span property="yui:type">object</span></code>
</h4>
<div class="detail">
<div class="description" property="yui:description">
Returns the index of the last item in the array
that contains the specified value, -1 if the
value isn't found.
method Array.lastIndexOf
</div>
</div>
<hr />
</div>
</div>
</div>
</div>
<div rel="yui:methods" resource="#methods">
<div class="section method details">
<h3 id="methods">Methods</h3>
<div class="content">
<div class="" rel="yui:method" resource="#method_Array.every">
<h4>
<a name="method_Array.every">Array.every</a></h4>
<div class="detail" >
<code>
static
boolean
<strong property="yui:name">Array.every</strong>
(
a
,
f
,
o
)
</code>
<div class="description" property="yui:description">
Executes the supplied function on each item in the array.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">a</span>
<<span property="yui:type">Array</span>>
</code>
<span property="yui:description"> the array to iterate</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">f</span>
<<span property="yui:type">Function</span>>
</code>
<span property="yui:description"> the function to execute on each item</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">o</span>
<<span property="yui:type">object</span>>
</code>
<span property="yui:description"> Optional context object</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
boolean
</code></dt>
<dd property="yui:returnInfo">true if every item in the array returns true
from the supplied function.</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_Array.filter">
<h4>
<a name="method_Array.filter">Array.filter</a></h4>
<div class="detail" >
<code>
static
Array
<strong property="yui:name">Array.filter</strong>
(
a
,
f
,
o
)
</code>
<div class="description" property="yui:description">
Executes the supplied function on each item in the array.
Returns a new array containing the items that the supplied
function returned true for.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">a</span>
<<span property="yui:type">Array</span>>
</code>
<span property="yui:description"> the array to iterate</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">f</span>
<<span property="yui:type">Function</span>>
</code>
<span property="yui:description"> the function to execute on each item</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">o</span>
<<span property="yui:type">object</span>>
</code>
<span property="yui:description"> Optional context object</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
Array
</code></dt>
<dd property="yui:returnInfo">The items on which the supplied function
returned true. If no items matched an empty array is
returned.</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_Array.find">
<h4>
<a name="method_Array.find">Array.find</a></h4>
<div class="detail" >
<code>
static
object
<strong property="yui:name">Array.find</strong>
(
a
,
f
,
o
)
</code>
<div class="description" property="yui:description">
Executes the supplied function on each item in the array,
searching for the first item that matches the supplied
function.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">a</span>
<<span property="yui:type">Array</span>>
</code>
<span property="yui:description"> the array to search</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">f</span>
<<span property="yui:type">Function</span>>
</code>
<span property="yui:description"> the function to execute on each item.
Iteration is stopped as soon as this function returns true
on an item.</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">o</span>
<<span property="yui:type">object</span>>
</code>
<span property="yui:description"> Optional context object</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
object
</code></dt>
<dd property="yui:returnInfo">the first item that the supplied function
returns true for, or null if it never returns true</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_Array.grep">
<h4>
<a name="method_Array.grep">Array.grep</a></h4>
<div class="detail" >
<code>
static
Array
<strong property="yui:name">Array.grep</strong>
(
a
,
pattern
)
</code>
<div class="description" property="yui:description">
Iterates over an array, returning a new array of all the elements
that match the supplied regular expression
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">a</span>
<<span property="yui:type">Array</span>>
</code>
<span property="yui:description"> a collection to iterate over</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">pattern</span>
<<span property="yui:type">RegExp</span>>
</code>
<span property="yui:description"> The regular expression to test against
each item</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
Array
</code></dt>
<dd property="yui:returnInfo">All the items in the collection that
produce a match against the supplied regular expression.
If no items match, an empty array is returned.</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_Array.map">
<h4>
<a name="method_Array.map">Array.map</a></h4>
<div class="detail" >
<code>
static
Array
<strong property="yui:name">Array.map</strong>
(
a
,
f
,
o
)
</code>
<div class="description" property="yui:description">
Executes the supplied function on each item in the array.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">a</span>
<<span property="yui:type">Array</span>>
</code>
<span property="yui:description"> the array to iterate</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">f</span>
<<span property="yui:type">Function</span>>
</code>
<span property="yui:description"> the function to execute on each item</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">o</span>
<<span property="yui:type">object</span>>
</code>
<span property="yui:description"> Optional context object</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
Array
</code></dt>
<dd property="yui:returnInfo">A new array containing the return value
of the supplied function for each item in the original
array.</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_Array.partition">
<h4>
<a name="method_Array.partition">Array.partition</a></h4>
<div class="detail" >
<code>
static
<strong property="yui:name">Array.partition</strong>
(
a
,
o
)
</code>
<div class="description" property="yui:description">
Partitions an array into two new arrays, one with the items
that match the supplied function, and one with the items that
do not.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">a</span>
<<span property="yui:type">Array</span>>
</code>
<span property="yui:description"> a collection to iterate over</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">o</span>
<<span property="yui:type">object</span>>
</code>
<span property="yui:description"> Optional execution context of f.</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
</code></dt>
<dd property="yui:returnInfo">An object with two members, 'matches' and 'rejects',
that are arrays containing the items that were selected or
rejected by the test function (or an empty array).</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_Array.reduce">
<h4>
<a name="method_Array.reduce">Array.reduce</a></h4>
<div class="detail" >
<code>
static
<strong property="yui:name">Array.reduce</strong>
(
a
,
init
,
f
,
o
)
</code>
<div class="description" property="yui:description">
Executes the supplied function on each item in the array.
Reduce "folds" the array into a single value.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">a</span>
<<span property="yui:type">Array</span>>
</code>
<span property="yui:description"> the array to iterate</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">init</span>
<<span property="yui:type">object</span>>
</code>
<span property="yui:description"> The initial value to start from</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">f</span>
<<span property="yui:type">Function</span>>
</code>
<span property="yui:description"> the function to execute on each item. It
is responsible for returning the updated value of the
computation.</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">o</span>
<<span property="yui:type">object</span>>
</code>
<span property="yui:description"> Optional context object</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
</code></dt>
<dd property="yui:returnInfo">A value that results from iteratively applying the
supplied function to each element in the array.</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_Array.reject">
<h4>
<a name="method_Array.reject">Array.reject</a></h4>
<div class="detail" >
<code>
static
Array
<strong property="yui:name">Array.reject</strong>
(
a
,
f
,
o
)
</code>
<div class="description" property="yui:description">
The inverse of filter. Executes the supplied function on each item.
Returns a new array containing the items that the supplied
function returned *false* for.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">a</span>
<<span property="yui:type">Array</span>>
</code>
<span property="yui:description"> the array to iterate</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">f</span>
<<span property="yui:type">Function</span>>
</code>
<span property="yui:description"> the function to execute on each item</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">o</span>
<<span property="yui:type">object</span>>
</code>
<span property="yui:description"> Optional context object</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
Array
</code></dt>
<dd property="yui:returnInfo">The items on which the supplied function
returned false.</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_Array.unique">
<h4>
<a name="method_Array.unique">Array.unique</a></h4>
<div class="detail" >
<code>
static
Array
<strong property="yui:name">Array.unique</strong>
(
a
,
sort
)
</code>
<div class="description" property="yui:description">
Returns a copy of the array with the duplicate entries removed
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">a</span>
<<span property="yui:type">Array</span>>
</code>
<span property="yui:description"> the array to find the subset of uniques for</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">sort</span>
<<span property="yui:type">bool</span>>
</code>
<span property="yui:description"> flag to denote if the array is sorted or not. Defaults to false, the more general operation</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
Array
</code></dt>
<dd property="yui:returnInfo">a copy of the array with duplicate entries removed</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_Array.zip">
<h4>
<a name="method_Array.zip">Array.zip</a></h4>
<div class="detail" >
<code>
static
<strong property="yui:name">Array.zip</strong>
(
a
,
a2
)
</code>
<div class="description" property="yui:description">
Creates an array of arrays by pairing the corresponding
elements of two arrays together into a new array.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">a</span>
<<span property="yui:type">Array</span>>
</code>
<span property="yui:description"> a collection to iterate over</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">a2</span>
<<span property="yui:type">Array</span>>
</code>
<span property="yui:description"> another collection whose members will be
paired with members of the first parameter</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
</code></dt>
<dd property="yui:returnInfo">An array of arrays formed by pairing each element
of the first collection with an item in the second collection
having the corresponding index.</dd>
</dl>
</div>
</div>
<hr />
</div>
</div>
</div>
</div>
<div rel="yui:events" resource="#events">
</div>
<div rel="yui:attributes" resource="#configattributes">
</div>
</div>
</div>
<div class="yui-b">
<div class="nav">
<div id="moduleList" class="module">
<h4>Modules</h4>
<ul class="content">
<li class=""><a href="module_anim.html" title="anim">anim</a></li>
<li class=""><a href="module_async-queue.html" title="async-queue">async-queue</a></li>
<li class=""><a href="module_attribute.html" title="attribute">attribute</a></li>
<li class=""><a href="module_base.html" title="base">base</a></li>
<li class=""><a href="module_cache.html" title="cache">cache</a></li>
<li class=""><a href="module_classnamemanager.html" title="classnamemanager">classnamemanager</a></li>
<li class="selected"><a href="module_collection.html" title="collection">collection</a></li>
<li class=""><a href="module_console.html" title="console">console</a></li>
<li class=""><a href="module_console-filters.html" title="console-filters">console-filters</a></li>
<li class=""><a href="module_cookie.html" title="cookie">cookie</a></li>
<li class=""><a href="module_dataschema.html" title="dataschema">dataschema</a></li>
<li class=""><a href="module_datasource.html" title="datasource">datasource</a></li>
<li class=""><a href="module_datatype.html" title="datatype">datatype</a></li>
<li class=""><a href="module_dd.html" title="dd">dd</a></li>
<li class=""><a href="module_dom.html" title="dom">dom</a></li>
<li class=""><a href="module_dump.html" title="dump">dump</a></li>
<li class=""><a href="module_event.html" title="event">event</a></li>
<li class=""><a href="module_event-custom.html" title="event-custom">event-custom</a></li>
<li class=""><a href="module_event-simulate.html" title="event-simulate">event-simulate</a></li>
<li class=""><a href="module_history.html" title="history">history</a></li>
<li class=""><a href="module_imageloader.html" title="imageloader">imageloader</a></li>
<li class=""><a href="module_io.html" title="io">io</a></li>
<li class=""><a href="module_json.html" title="json">json</a></li>
<li class=""><a href="module_node.html" title="node">node</a></li>
<li class=""><a href="module_node-focusmanager.html" title="node-focusmanager">node-focusmanager</a></li>
<li class=""><a href="module_node-menunav.html" title="node-menunav">node-menunav</a></li>
<li class=""><a href="module_oop.html" title="oop">oop</a></li>
<li class=""><a href="module_overlay.html" title="overlay">overlay</a></li>
<li class=""><a href="module_plugin.html" title="plugin">plugin</a></li>
<li class=""><a href="module_profiler.html" title="profiler">profiler</a></li>
<li class=""><a href="module_queue-promote.html" title="queue-promote">queue-promote</a></li>
<li class=""><a href="module_slider.html" title="slider">slider</a></li>
<li class=""><a href="module_stylesheet.html" title="stylesheet">stylesheet</a></li>
<li class=""><a href="module_substitute.html" title="substitute">substitute</a></li>
<li class=""><a href="module_test.html" title="test">test</a></li>
<li class=""><a href="module_widget.html" title="widget">widget</a></li>
<li class=""><a href="module_widget-position.html" title="widget-position">widget-position</a></li>
<li class=""><a href="module_widget-position-ext.html" title="widget-position-ext">widget-position-ext</a></li>
<li class=""><a href="module_widget-stack.html" title="widget-stack">widget-stack</a></li>
<li class=""><a href="module_widget-stdmod.html" title="widget-stdmod">widget-stdmod</a></li>
<li class=""><a href="module_yui.html" title="yui">yui</a></li>
</ul>
</div>
<div id="classList" class="module">
<h4>Classes</h4>
<ul class="content">
<li class="selected"><a href="YUI~array~extras.html" title="YUI~array~extras">YUI~array~extras</a></li>
</ul>
</div>
<div id="fileList" class="module">
<h4>Files</h4>
<ul class="content">
<li class=""><a href="array-extras.js.html" title="array-extras.js">array-extras.js</a></li>
</ul>
</div>
<div id="propertyList" class="module">
<h4>Properties</h4>
<ul class="content">
<li class=""><a href="#property_lastIndexOf" title="lastIndexOf">lastIndexOf</a></li>
</ul>
</div>
<div id="methodsList" class="module">
<h4>Methods</h4>
<ul class="content">
<li class=""><a href="#method_Array.every" title="Array.every">Array.every</a></li>
<li class=""><a href="#method_Array.filter" title="Array.filter">Array.filter</a></li>
<li class=""><a href="#method_Array.find" title="Array.find">Array.find</a></li>
<li class=""><a href="#method_Array.grep" title="Array.grep">Array.grep</a></li>
<li class=""><a href="#method_Array.map" title="Array.map">Array.map</a></li>
<li class=""><a href="#method_Array.partition" title="Array.partition">Array.partition</a></li>
<li class=""><a href="#method_Array.reduce" title="Array.reduce">Array.reduce</a></li>
<li class=""><a href="#method_Array.reject" title="Array.reject">Array.reject</a></li>
<li class=""><a href="#method_Array.unique" title="Array.unique">Array.unique</a></li>
<li class=""><a href="#method_Array.zip" title="Array.zip">Array.zip</a></li>
</ul>
</div>
</div>
</div>
</div>
<div id="ft">
<hr />
Copyright © 2009 Yahoo! Inc. All rights reserved.
</div>
</div>
<script type="text/javascript">
ALL_YUI_PROPS = [{"access": "", "host": "YUI~array~extras", "name": "Array.every", "url": "YUI~array~extras.html#method_Array.every", "type": "method"}, {"access": "", "host": "YUI~array~extras", "name": "Array.filter", "url": "YUI~array~extras.html#method_Array.filter", "type": "method"}, {"access": "", "host": "YUI~array~extras", "name": "Array.find", "url": "YUI~array~extras.html#method_Array.find", "type": "method"}, {"access": "", "host": "YUI~array~extras", "name": "Array.grep", "url": "YUI~array~extras.html#method_Array.grep", "type": "method"}, {"access": "", "host": "YUI~array~extras", "name": "Array.map", "url": "YUI~array~extras.html#method_Array.map", "type": "method"}, {"access": "", "host": "YUI~array~extras", "name": "Array.partition", "url": "YUI~array~extras.html#method_Array.partition", "type": "method"}, {"access": "", "host": "YUI~array~extras", "name": "Array.reduce", "url": "YUI~array~extras.html#method_Array.reduce", "type": "method"}, {"access": "", "host": "YUI~array~extras", "name": "Array.reject", "url": "YUI~array~extras.html#method_Array.reject", "type": "method"}, {"access": "", "host": "YUI~array~extras", "name": "Array.unique", "url": "YUI~array~extras.html#method_Array.unique", "type": "method"}, {"access": "", "host": "YUI~array~extras", "name": "Array.zip", "url": "YUI~array~extras.html#method_Array.zip", "type": "method"}, {"access": "", "host": "YUI~array~extras", "name": "lastIndexOf", "url": "YUI~array~extras.html#property_lastIndexOf", "type": "property"}];
</script>
</body>
</html>