@mapgis/webclient-common
Version:
mapgis ES6 format for igserver
16,222 lines • 235 kB
HTML
<header id="page-title" class="page-title">
<span class="page-title-main">类名</span>
<span class="page-title-sub">Collection</span>
</header>
<section>
<article>
<div class="container-overview">
<div class='vertical-section'>
<div class="members">
<div class="member">
<h4 class="name" id="Collection">
<a class="href-link" href="#Collection">#</a>
<span class="code-name" id="Collection" style="font-size:30px">
new Collection<span class="signature">(collection)</span>
</span>
</h4>
<div class="description">
<p>集合类用来存储相同类型的项的数组,它为处理集合中的元素提供了有用的实用方法,包括filter()、find()和reduce()等。<br>
集合中的元素可以是任何类型。例如,GraphicsLayer.graphics是存储在GraphicsLayer中的图形的集合。您可以使用Collection类中的方法来添加、删除、重新排序或操作GraphicsLayer中的图形。<br>
集合的另一个示例是Map.layers,它是搜友地图的集合。</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>collection</code></td>
<td class="type">
<span class="param-type">
Array.<*>
</span>
</td>
<td class="description last"><p>构造参数,要传入的元素数组</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<p class="summary"><h5>支持如下方法:</h5>
<a href='#add'>[1、添加一个元素到集合中]</a><br/>
<a href='#add2'>[2、添加一个元素到集合中的指定位置]</a><br/>
<a href='#addMany'>[3、添加多个元素到集合中]</a><br/>
<a href='#addMany2'>[4、添加多个元素到集合中的指定位置]</a><br/>
<a href='#at'>[5、返回指定下标处的元素]</a><br/>
<a href='#clone'>[6、克隆并返回一个新集合对象]</a><br/>
<a href='#concat'>[7、将一个数组或者集合对象链接到当前集合对象末尾]</a><br/>
<a href='#every'>[8、检测数组所有元素是否都符合指定条件]</a><br/>
<a href='#filter'>[9、通过一个过滤条件(函数提供)来过滤并返回元素]</a><br/>
<a href='#find'>[10、返回第一个符合过滤条件(函数提供)的元素]</a><br/>
<a href='#findIndex'>[11、返回第一个符合过滤条件(函数提供)的元素的下标]</a><br/>
<a href='#flatten'>[12、扁平化一个集合对象]</a><br/>
<a href='#forEach'>[13、对集合中的所有元素执行传入的函数]</a><br/>
<a href='#getItemAt'>[14、获取指定下标的元素]</a><br/>
<a href='#includes'>[15、判断集合中是否包含该元素]</a><br/>
<a href='#indexOf'>[16、返回元素在集合中的下标]</a><br/>
<a href='#indexOf2'>[17、判断集合中是否包含该元素-选择起始下标]</a><br/>
<a href='#isCollection'>[18、判断传入的对象是否是一个集合对象]</a><br/>
<a href='#join'>[19、通过传入一个分隔符,将集合中的元素通过分隔符拼接成一个字符串并返回]</a><br/>
<a href='#lastIndexOf'>[20、从集合的最末尾开始,寻找该元素,并返回元素下标]</a><br/>
<a href='#lastIndexOf2'>[21、从集合的最末尾开始,寻找该元素,并返回元素下标 - 指定起始额位置]</a><br/>
<a href='#map'>[22、通过一个遍历函数来遍历该集合下的所有元素,并返回一个新集合对象]</a><br/>
<a href='#pop'>[23、删除并返回集合的最后一个元素]</a><br/>
<a href='#push[24、添加一个元素到集合中]</a><br/>
<a href='#reduce'>[25、接收一个函数做为累加器,将集合中的每一个元素(下标从小到大的顺序)进行累加,最后返回一个对象]</a><br/>
<a href='#reduceRight'>[26、接收一个函数做为累加器,将集合中的每一个元素(下标从大到小的顺序)进行累加,最后返回一个对象]</a><br/>
<a href='#remove'>[27、删除一个元素,仅会删除找到的第一个元素,并发送删除事件]</a><br/>
<a href='#removeAll'>[28、删除集合中的所有元素,删除完成后会发送数据变更事件]</a><br/>
<a href='#removeAt'>[29、删除指定下标的元素]</a><br/>
<a href='#removeMany'>[30、删除集合中的多个元素,删除完成后会发送数据变更事件]</a><br/>
<a href='#reorder'>[31、将指的元素调整到集合中指的下标位置]</a><br/>
<a href='#reverse'>[32、将集合对象中的元素反转,并返回新集合对象]</a><br/>
<a href='#shift'>[33、删除并返回集合的第一个元素]</a><br/>
<a href='#slice'>[34、截取集合中从start开始到end下标的元素,并返回一个新集合对象]</a><br/>
<a href='#some'>[35、判断集合对象中的元素是否满足过滤条件]</a><br/>
<a href='#sort'>[36、通过一个排序函数来对当前的集合进行排序,之后返回一个新集合对象,参考js的sort函数]</a><br/>
<a href='#splice'>[37、向集合中删除一个元素]</a><br/>
<a href='#splice2'>[38、向集合中添加一个元素]</a><br/>
<a href='#toArray'>[39、返回集合对象中元素组成的数组]</a><br/>
<a href='#unshift'>[40、向集合起始位置添加一个或多个元素]</a><br/>
<a href='#all'>[41、获取集合中的所有元素并返回一个数组]</a><br/>
<a href='#unique'>[42、去除集合中的重复元素]</a><br/>
<a href='#createInstance'>[43、创建实例]</a><br/></p>
<h5>示例</h5>
<p class="code-caption"><h7 id='Collection'>初始化一个集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])</code></pre>
</div>
</div>
</div>
</div>
<div class='vertical-section'>
<h3 id='member'>成员变量</h3>
<h4 style="margin-top: 20px;margin-bottom: 20px;">成员变量概述</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code><a href="#items">items</a></code></td>
<td class="name">
<code>
<span class="param-type">
Array.<any>
</span>
</code>
</td>
<td class="name"><code><p>items</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#items">items</a></code></td>
<td class="name">
<code>
<span class="param-type">
Array.<any>
</span>
</code>
</td>
<td class="name"><code><p>items</p></code></td>
</tr>
</tbody>
</table>
</div>
<h4 style="margin-top: 20px;margin-bottom: 20px;">成员变量详情</h4>
<div class="members">
<div class="member">
<span class="method-parameter is-pulled-right">
<label>类型:</label>
<span class="param-type">
Array.<any>
</span>
</span>
<h4 class="name" id="items">
<a class="href-link" href="#items">#</a>
<span class="code-name">
items
</span>
</h4>
<div class="description">
<p>items</p>
</div>
<dl class="details">
</dl>
</div>
<div class="member">
<span class="method-parameter is-pulled-right">
<label>类型:</label>
<span class="param-type">
Array.<any>
</span>
</span>
<h4 class="name" id="items">
<a class="href-link" href="#items">#</a>
<span class='tag'>readonly</span>
<span class="code-name">
items
</span>
</h4>
<div class="description">
<p>items</p>
</div>
<dl class="details">
</dl>
</div>
</div>
</div>
<div class='vertical-section'>
<h3 id='function'>方法</h3>
<h4 style="margin-top: 20px;margin-bottom: 20px;">方法概述</h4>
<div class="members">
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>返回值类型</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code><a href="#isCollection">isCollection</a></code></td>
<td class="name">
<code>
<span class="param-type">
Boolean
</span>
</code>
</td>
<td class="name"><code><p>判断传入的对象是否是一个集合对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#add">add</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>添加一个元素到集合中</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#addMany">addMany</a></code></td>
<td class="name">
<code>
</code>
</td>
<td class="name"><code><p>添加多个元素到集合中,添加完成后会发送数据变更事件</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#all">all</a></code></td>
<td class="name">
<code>
<span class="param-type">
Array.<*>
</span>
</code>
</td>
<td class="name"><code><p>获取集合中的所有元素并返回一个数组</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#at">at</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>返回指定下标处的元素</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#clone">clone</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>克隆并返回一个新集合对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#concat">concat</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>将一个数组或者集合对象链接到当前集合对象末尾</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#createInstance">createInstance</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>创建实例,可由子类重载</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#every">every</a></code></td>
<td class="name">
<code>
<span class="param-type">
Boolean
</span>
</code>
</td>
<td class="name"><code><p>检测数组所有元素是否都符合指定条件(通过函数提供)</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#filter">filter</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>通过一个过滤条件(函数提供)来过滤并返回元素</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#find">find</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>返回第一个符合过滤条件(函数提供)的元素,如果没找到则返回undefined</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#findIndex">findIndex</a></code></td>
<td class="name">
<code>
<span class="param-type">
Number
</span>
</code>
</td>
<td class="name"><code><p>返回第一个符合过滤条件(函数提供)的元素的下标,如果没找到则返回-1</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#flatten">flatten</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>扁平化一个集合对象,通过传入的扁平化函数来指定要扁平化的对象数组,直到指定的对象数组为空或者元素数量为0,之后返回一个新集合对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#forEach">forEach</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>对集合中的所有元素执行传入的函数</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#getItemAt">getItemAt</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>获取指定下标的元素,没找到则返回undefined</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#includes">includes</a></code></td>
<td class="name">
<code>
<span class="param-type">
Boolean
</span>
</code>
</td>
<td class="name"><code><p>判断集合中是否包含该元素</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#indexOf">indexOf</a></code></td>
<td class="name">
<code>
<span class="param-type">
Number
</span>
</code>
</td>
<td class="name"><code><p>返回元素在集合中的下标</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#join">join</a></code></td>
<td class="name">
<code>
<span class="param-type">
String
</span>
</code>
</td>
<td class="name"><code><p>通过传入一个分隔符,将集合中的元素通过分隔符拼接成一个字符串并返回</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#lastIndexOf">lastIndexOf</a></code></td>
<td class="name">
<code>
<span class="param-type">
Number
</span>
</code>
</td>
<td class="name"><code><p>从集合的最末尾开始,寻找该元素,并返回元素下标</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#map">map</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>通过一个遍历函数来遍历该集合下的所有元素,并返回一个新集合对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#pop">pop</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>删除并返回集合的最后一个元素</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#push">push</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>添加一个元素到集合中</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#reduce">reduce</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>接收一个函数做为累加器,将集合中的每一个元素(下标从小到大的顺序)进行累加,最后返回一个对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#reduceRight">reduceRight</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>接收一个函数做为累加器,将集合中的每一个元素(下标从大到小的顺序)进行累加,最后返回一个对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#remove">remove</a></code></td>
<td class="name">
<code>
<span class="param-type">
Boolean
</span>
</code>
</td>
<td class="name"><code><p>删除一个元素,仅会删除找到的第一个元素,并发送删除事件</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#removeAll">removeAll</a></code></td>
<td class="name">
<code>
</code>
</td>
<td class="name"><code><p>删除集合中的所有元素,删除完成后会发送数据变更事件</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#removeAt">removeAt</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>删除指定下标的元素</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#removeMany">removeMany</a></code></td>
<td class="name">
<code>
<span class="param-type">
Array.<*>
</span>
</code>
</td>
<td class="name"><code><p>删除集合中的多个元素,删除完成后会发送数据变更事件</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#reorder">reorder</a></code></td>
<td class="name">
<code>
</code>
</td>
<td class="name"><code><p>将指的元素调整到集合中指的下标位置</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#reverse">reverse</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>将集合对象中的元素反转,并返回新集合对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#shift">shift</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>删除并返回集合的第一个元素(元素下标为0)</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#slice">slice</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>截取集合中从start开始到end下标的元素,并返回一个新集合对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#some">some</a></code></td>
<td class="name">
<code>
<span class="param-type">
Boolean
</span>
</code>
</td>
<td class="name"><code><p>判断集合对象中的元素是否满足过滤条件,只要有一个元素满足过滤条件,则会返回true,如果都不满足过滤条件,则返回false</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#sort">sort</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>通过一个排序函数来对当前的集合进行排序,之后返回一个新集合对象,参考js的sort函数</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#splice">splice</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>向集合中删除或添加一个元素,参考js的splice方法</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#toArray">toArray</a></code></td>
<td class="name">
<code>
<span class="param-type">
Array
</span>
</code>
</td>
<td class="name"><code><p>返回集合对象中元素组成的数组</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#unique">unique</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>去除集合中的重复元素</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#unshift">unshift</a></code></td>
<td class="name">
<code>
</code>
</td>
<td class="name"><code><p>向集合起始位置添加一个或多个元素</p></code></td>
</tr>
</tbody>
</table>
</div>
<h4 style="margin-top: 20px;margin-bottom: 20px;">方法详情</h4>
<div class="member">
<h4 class="name" id=".isCollection">
<a class="href-link" href="#.isCollection">#</a>
<span class='tag'>static</span>
<span class="code-name" id="isCollection" style="font-size:30px">
isCollection<span class="signature">(item)</span>
</span>
</h4>
<div class="description">
<p>判断传入的对象是否是一个集合对象</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要判断的对象</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>是否是集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Boolean
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='isCollection'>判断传入的对象是否是一个集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const isCollection = Collection.isCollection(collection)</code></pre>
</div>
<div class="member">
<h4 class="name" id="add">
<a class="href-link" href="#add">#</a>
<span class="code-name" id="add" style="font-size:30px">
add<span class="signature">(item, index)</span>
</span>
</h4>
<div class="description">
<p>添加一个元素到集合中</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要添加的元素</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>指的元素要添加的位置,如果不指定,默认添加到集合末尾</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>添加完元素后的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='add'>添加一个元素到集合中</h7></p>
<pre class="prettyprint"><code>const collection = new Collection()
collection.add({
key: 'value'
})</code></pre>
<p class="code-caption"><h7 id='add2'>添加一个元素到集合中的指定位置</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.add({
key: 'value'
}, 1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="addMany">
<a class="href-link" href="#addMany">#</a>
<span class="code-name" id="addMany" style="font-size:30px">
addMany<span class="signature">(items, index)</span>
</span>
</h4>
<div class="description">
<p>添加多个元素到集合中,添加完成后会发送数据变更事件</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>items</code></td>
<td class="type">
<span class="param-type">
Array.<*>
</span>
</td>
<td class="description last"><p>要添加的多个元素</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>指的元素要添加的位置,如果不指定,默认添加到集合末尾</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<h5>示例</h5>
<p class="code-caption"><h7 id='addMany'>添加多个元素到集合中</h7></p>
<pre class="prettyprint"><code>const collection = new Collection()
collection.addMany([1, 2, 3])</code></pre>
<p class="code-caption"><h7 id='addMany2'>添加多个元素到集合中的指定位置</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.addMany([1, 2, 3], 2)</code></pre>
</div>
<div class="member">
<h4 class="name" id="all">
<a class="href-link" href="#all">#</a>
<span class="code-name" id="all" style="font-size:30px">
all<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>获取集合中的所有元素并返回一个数组</p>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>集合中元素构成的数组</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Array.<*>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='toArray'>返回集合对象中元素组成的数组</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.all()</code></pre>
</div>
<div class="member">
<h4 class="name" id="at">
<a class="href-link" href="#at">#</a>
<span class="code-name" id="at" style="font-size:30px">
at<span class="signature">(index)</span>
</span>
</h4>
<div class="description">
<p>返回指定下标处的元素</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>元素下标,默认从0开始,允许使用正整数和负整数,负整数从集合中的最后一个元素开始倒数</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>查询到的元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='at'>返回指定下标处的元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const item = collection.at(1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="clone">
<a class="href-link" href="#clone">#</a>
<span class="code-name" id="clone" style="font-size:30px">
clone<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>克隆并返回一个新集合对象</p>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>克隆后的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='clone'>克隆并返回一个新集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const cloneObj = collection.clone()</code></pre>
</div>
<div class="member">
<h4 class="name" id="concat">
<a class="href-link" href="#concat">#</a>
<span class="code-name" id="concat" style="font-size:30px">
concat<span class="signature">(collection)</span>
</span>
</h4>
<div class="description">
<p>将一个数组或者集合对象链接到当前集合对象末尾</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>collection</code></td>
<td class="type">
<span class="param-type">
Array
</span>
|
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</td>
<td class="description last"><p>要链接的数组或者集合对象</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>链接后的新集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='concat'>将一个数组或者集合对象链接到当前集合对象末尾</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.concat([{'a': 1}, {'b': 2}])
collection.concat(new Collection([4, 5, 6]))</code></pre>
</div>
<div class="member">
<h4 class="name" id="createInstance">
<a class="href-link" href="#createInstance">#</a>
<span class="code-name" id="createInstance" style="font-size:30px">
createInstance<span class="signature">(item)</span>
</span>
</h4>
<div class="description">
<p>创建实例,可由子类重载</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要创建的实例对象</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>创建的实例对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
</div>
<div class="member">
<h4 class="name" id="every">
<a class="href-link" href="#every">#</a>
<span class="code-name" id="every" style="font-size:30px">
every<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>检测数组所有元素是否都符合指定条件(通过函数提供)</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>过滤条件</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>是否全部满足过滤条件</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Boolean
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='every'>检测数组所有元素是否都符合指定条件</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const isNumber = collection.every(function(item) {
return typeof item === 'number'
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="filter">
<a class="href-link" href="#filter">#</a>
<span class="code-name" id="filter" style="font-size:30px">
filter<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>通过一个过滤条件(函数提供)来过滤并返回元素</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>过滤条件,如果过滤条件不是函数,则返回undefined</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>过滤后的新集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='filter'>通过一个过滤条件(函数提供)来过滤并返回元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3, 4, 5])
const newCollection = collection.filter(function(item) {
return item > 2
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="find">
<a class="href-link" href="#find">#</a>
<span class="code-name" id="find" style="font-size:30px">
find<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>返回第一个符合过滤条件(函数提供)的元素,如果没找到则返回undefined</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>过滤条件,如果过滤条件不是函数,也返回undefined</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>第一个符合过滤条件的元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='find'>返回第一个符合过滤条件(函数提供)的元素,如果没找到则返回undefined</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3, 4, 5])
const item = collection.find(function(item) {
return item > 2
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="findIndex">
<a class="href-link" href="#findIndex">#</a>
<span class="code-name" id="findIndex" style="font-size:30px">
findIndex<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>返回第一个符合过滤条件(函数提供)的元素的下标,如果没找到则返回-1</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>过滤条件</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>第一个符合过滤条件(函数提供)的元素的下标</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Number
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='findIndex'>返回第一个符合过滤条件(函数提供)的元素的下标,如果没找到则返回-1</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3, 4, 5])
const index = collection.findIndex(function(item) {
return item > 1
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="flatten">
<a class="href-link" href="#flatten">#</a>
<span class="code-name" id="flatten" style="font-size:30px">
flatten<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>扁平化一个集合对象,通过传入的扁平化函数来指定要扁平化的对象数组,直到指定的对象数组为空或者元素数量为0,之后返回一个新集合对象</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>扁平化函数,通过该函数来指定要扁平化的对象数组,如果该函数不是一个函数对象,则返回undefined</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>扁平化后的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='flatten'>扁平化一个集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([{
layers: [1, 2, 3]
},{
items: [4, 5, 6]
}])
const flatten = collection.flatten(function(item) {
return item.layers || item.items
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="forEach">
<a class="href-link" href="#forEach">#</a>
<span class="code-name" id="forEach" style="font-size:30px">
forEach<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>对集合中的所有元素执行传入的函数</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>针对元素的执行函数,参考js数组的forEach方法</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>执行完函数后的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='forEach'>对集合中的所有元素执行传入的函数</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.forEach(function(item) {
console.log("item:", item)
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="getItemAt">
<a class="href-link" href="#getItemAt">#</a>
<span class="code-name" id="getItemAt" style="font-size:30px">
getItemAt<span class="signature">(index)</span>
</span>
</h4>
<div class="description">
<p>获取指定下标的元素,没找到则返回undefined</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>元素下标</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>该下标下的元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='getItemAt'>获取指定下标的元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const item = collection.getItemAt(1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="includes">
<a class="href-link" href="#includes">#</a>
<span class="code-name" id="includes" style="font-size:30px">
includes<span class="signature">(item)</span>
</span>
</h4>
<div class="description">
<p>判断集合中是否包含该元素</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要检查的元素对象</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>集合中是否包含该元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Boolean
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='includes'>判断集合中是否包含该元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const isInclude = collection.includes(2)</code></pre>
</div>
<div class="member">
<h4 class="name" id="indexOf">
<a class="href-link" href="#indexOf">#</a>
<span class="code-name" id="indexOf" style="font-size:30px">
indexOf<span class="signature">(item, fromIndex)</span>
</span>
</h4>
<div class="description">
<p>返回元素在集合中的下标</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要在集合中寻找的元素</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>fromIndex</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>选择起始下标,默认为0,即从何处开始寻找</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>元素在集合中的下标</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Number
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='indexOf'>判断集合中是否包含该元素</h7></p>
<pre class="prettyprint"><code>const item = {
'a': 1
}
const collection = new Collection([item, 2, 3])
const index = collection.indexOf(item)</code></pre>
<p class="code-caption"><h7 id='indexOf2'>判断集合中是否包含该元素-选择起始下标</h7></p>
<pre class="prettyprint"><code>const item = {
'a': 1
}
const collection = new Collection([item, 2, 3, item])
const index = collection.indexOf(item, 1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="join">
<a class="href-link" href="#join">#</a>
<span class="code-name" id="join" style="font-size:30px">
join<span class="signature">(separator)</span>
</span>
</h4>
<div class="description">
<p>通过传入一个分隔符,将集合中的元素通过分隔符拼接成一个字符串并返回</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>separator</code></td>
<td class="type">
<span class="param-type">
String
</span>
</td>
<td class="description last"><p>分割符号</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>拼接完成的字符串</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
String
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='join'>通过传入一个分隔符,将集合中的元素通过分隔符拼接成一个字符串并返回</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const str = collection.join(',')</code></pre>
</div>
<div class="member">
<h4 class="name" id="lastIndexOf">
<a class="href-link" href="#lastIndexOf">#</a>
<span class="code-name" id="lastIndexOf" style="font-size:30px">
lastIndexOf<span class="signature">(item, fromIndex)</span>
</span>
</h4>
<div class="description">
<p>从集合的最末尾开始,寻找该元素,并返回元素下标</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要寻找的元素</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>fromIndex</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>从何处开始查找,默认为集合的长度-1</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>第一个找到的元素下标,未找到则返回-1</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Number
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='lastIndexOf'>从集合的最末尾开始,寻找该元素,并返回元素下标</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const index = collection.lastIndexOf(3)</code></pre>
<p class="code-caption"><h7 id='lastIndexOf2'>从集合的最末尾开始,寻找该元素,并返回元素下标 - 指定起始额位置</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3, 3, 3])
const index = collection.lastIndexOf(3, 3)</code></pre>
</div>
<div class="member">
<h4 class="name" id="map">
<a class="href-link" href="#map">#</a>
<span class="code-name" id="map" style="font-size:30px">
map<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>通过一个遍历函数来遍历该集合下的所有元素,并返回一个新集合对象</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>遍历函数</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>遍历后的新集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='map'>通过一个遍历函数来遍历该集合下的所有元素,并返回一个新集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const newCollection = collection.map(function (item) {
return item + 1
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="pop">
<a class="href-link" href="#pop">#</a>
<span class="code-name" id="pop" style="font-size:30px">
pop<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>删除并返回集合的最后一个元素</p>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>集合的最后一个元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='pop'>删除并返回集合的最后一个元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const item = collection.pop()</code></pre>
</div>
<div class="member">
<h4 class="name" id="push">
<a class="href-link" href="#push">#</a>
<span class="code-name" id="push" style="font-size:30px">
push<span class="signature">(item)</span>
</span>
</h4>
<div class="description">
<p>添加一个元素到集合中</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要添加的元素</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>添加完元素后的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='push'>添加一个元素到集合中</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.push(4)</code></pre>
</div>
<div class="member">
<h4 class="name" id="reduce">
<a class="href-link" href="#reduce">#</a>
<span class="code-name" id="reduce" style="font-size:30px">
reduce<span class="signature">(fn, baseValue)</span>
</span>
</h4>
<div class="description">
<p>接收一个函数做为累加器,将集合中的每一个元素(下标从小到大的顺序)进行累加,最后返回一个对象</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>累加器函数</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>baseValue</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>累加的基础对象</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>累加后的对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='reduce'>接收一个函数做为累加器,将集合中的每一个元素(下标从小到大的顺序)进行累加,最后返回一个对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const sum = collection.reduce(function (reduceCarry, item) {
return reduceCarry += item
}, 0)</code></pre>
</div>
<div class="member">
<h4 class="name" id="reduceRight">
<a class="href-link" href="#reduceRight">#</a>
<span class="code-name" id="reduceRight" style="font-size:30px">
reduceRight<span class="signature">(fn, baseValue)</span>
</span>
</h4>
<div class="description">
<p>接收一个函数做为累加器,将集合中的每一个元素(下标从大到小的顺序)进行累加,最后返回一个对象</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>累加器函数</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>baseValue</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>累加的基础对象</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>累加后的对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='reduceRight'>接收一个函数做为累加器,将集合中的每一个元素(下标从大到小的顺序)进行累加,最后返回一个对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const sum = collection.reduce(function (reduceCarry, item) {
console.log(item)
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="remove">
<a class="href-link" href="#remove">#</a>
<span class="code-name" id="remove" style="font-size:30px">
remove<span class="signature">(item)</span>
</span>
</h4>
<div class="description">
<p>删除一个元素,仅会删除找到的第一个元素,并发送删除事件</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要删除的元素</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>元素是否删除成功</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Boolean
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='remove'>删除一个元素,仅会删除找到的第一个元素,并发送删除事件</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.remove(1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="removeAll">
<a class="href-link" href="#removeAll">#</a>
<span class="code-name" id="removeAll" style="font-size:30px">
removeAll<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>删除集合中的所有元素,删除完成后会发送数据变更事件</p>
</div>
<dl class="details">
</dl>
<h5>示例</h5>
<p class="code-caption"><h7 id='removeAll'>删除集合中的所有元素,删除完成后会发送数据变更事件</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.removeAll(1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="removeAt">
<a class="href-link" href="#removeAt">#</a>
<span class="code-name" id="removeAt" style="font-size:30px">
removeAt<span class="signature">(index)</span>
</span>
</h4>
<div class="description">
<p>删除指定下标的元素</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>元素的下标,从0开始</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>删除后的元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='removeAt'>删除指定下标的元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.removeAt(1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="removeMany">
<a class="href-link" href="#removeMany">#</a>
<span class="code-name" id="removeMany" style="font-size:30px">
removeMany<span class="signature">(items)</span>
</span>
</h4>
<div class="description">
<p>删除集合中的多个元素,删除完成后会发送数据变更事件</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>items</code></td>
<td class="type">
<span class="param-type">
Array.<*>
</span>
</td>
<td class="description last"><p>要添加的多个元素</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>被删除的元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Array.<*>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='removeMany'>删除集合中的多个元素,删除完成后会发送数据变更事件</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.removeMany([1, 2])</code></pre>
</div>
<div class="member">
<h4 class="name" id="reorder">
<a class="href-link" href="#reorder">#</a>
<span class="code-name" id="reorder" style="font-size:30px">
reorder<span class="signature">(item, index)</span>
</span>
</h4>
<div class="description">
<p>将指的元素调整到集合中指的下标位置</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要排序的元素</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>元素要调整到的位置</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<h5>示例</h5>
<p class="code-caption"><h7 id='reorder'>将指的元素调整到集合中指的下标位置</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.reorder(1, 2)</code></pre>
</div>
<div class="member">
<h4 class="name" id="reverse">
<a class="href-link" href="#reverse">#</a>
<span class="code-name" id="reverse" style="font-size:30px">
reverse<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>将集合对象中的元素反转,并返回新集合对象</p>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>新的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='reverse'>将集合对象中的元素反转,并返回新集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const newCollection = collection.reverse()</code></pre>
</div>
<div class="member">
<h4 class="name" id="shift">
<a class="href-link" href="#shift">#</a>
<span class="code-name" id="shift" style="font-size:30px">
shift<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>删除并返回集合的第一个元素(元素下标为0)</p>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>集合的第一个元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='reverse'>删除并返回集合的第一个元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const item = collection.shift()</code></pre>
</div>
<div class="member">
<h4 class="name" id="slice">
<a class="href-link" href="#slice">#</a>
<span class="code-name" id="slice" style="font-size:30px">
slice<span class="signature">(start, end)</span>
</span>
</h4>
<div class="description">
<p>截取集合中从start开始到end下标的元素,并返回一个新集合对象</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>从0开始的元素小标</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>end</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>截至的元素下标,不填则默认到集合最后一个元素</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>新集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='slice'>截取集合中从start开始到end下标的元素,并返回一个新集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3, 4, 5])
const newCollection = collection.slice(1, 3)</code></pre>
</div>
<div class="member">
<h4 class="name" id="some">
<a class="href-link" href="#some">#</a>
<span class="code-name" id="some" style="font-size:30px">
some<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>判断集合对象中的元素是否满足过滤条件,只要有一个元素满足过滤条件,则会返回true,如果都不满足过滤条件,则返回false</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>过滤条件,如果过滤条件不是函数,也返回false</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>是否满足过滤条件</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Boolean
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='some'>判断集合对象中的元素是否满足过滤条件</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3, 4, 5])
const flag = collection.some(function (item) {
return item === 1
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="sort">
<a class="href-link" href="#sort">#</a>
<span class="code-name" id="sort" style="font-size:30px">
sort<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>通过一个排序函数来对当前的集合进行排序,之后返回一个新集合对象,参考js的sort函数</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>排序函数,不填则默认按从小到达排序</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>新的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='sort'>通过一个排序函数来对当前的集合进行排序,之后返回一个新集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([{
'a': 2
},{
'a': 1
},{
'a': 3
}])
const newCollection = collection.sort(function (itemA, itemB) {
return itemA.a - itemB.a
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="splice">
<a class="href-link" href="#splice">#</a>
<span class="code-name" id="splice" style="font-size:30px">
splice<span class="signature">(start, deleteCount, …items)</span>
</span>
</h4>
<div class="description">
<p>向集合中删除或添加一个元素,参考js的splice方法</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>删除或添加的起始下标</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>deleteCount</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>删除或添加的数量</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>items</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要删除或添加的元素</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>新的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='splice'>向集合中删除一个元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const newCollection = collection.splice(1, 1)</code></pre>
<p class="code-caption"><h7 id='splice2'>向集合中添加一个元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.splice(1, 0, 1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="toArray">
<a class="href-link" href="#toArray">#</a>
<span class="code-name" id="toArray" style="font-size:30px">
toArray<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>返回集合对象中元素组成的数组</p>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>集合对象中元素组成的数组</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Array
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='toArray'>返回集合对象中元素组成的数组</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.toArray()</code></pre>
</div>
<div class="member">
<h4 class="name" id="unique">
<a class="href-link" href="#unique">#</a>
<span class="code-name" id="unique" style="font-size:30px">
unique<span class="signature">(key)</span>
</span>
</h4>
<div class="description">
<p>去除集合中的重复元素</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">
function
</span>
|
<span class="param-type">
String
</span>
</td>
<td class="description last"><p>指定一个去重函数或者要素的去重字段</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>去重后的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption">No Arguments</p>
<pre class="prettyprint"><code>const unique = new Collection([2, 1, 2, 3, 3, 4, 5, 1, 2]).unique();
console.log(unique); // [2, 1, 3, 4, 5]</code></pre>
<p class="code-caption">Property Name</p>
<pre class="prettyprint"><code>const students = new Collection([
{ name: 'Rick', grade: 'A'},
{ name: 'Mick', grade: 'B'},
{ name: 'Richard', grade: 'A'},
]);
// Students with unique grades.
students.unique('grade'); // [{ name: 'Rick', grade: 'A'}, { name: 'Mick', grade: 'B'}]</code></pre>
<p class="code-caption">With Callback</p>
<pre class="prettyprint"><code>const students = new Collection([
{ name: 'Rick', grade: 'A'},
{ name: 'Mick', grade: 'B'},
{ name: 'Richard', grade: 'A'},
]);
// Students with unique grades.
students.unique(s => s.grade); // [{ name: 'Rick', grade: 'A'}, { name: 'Mick', grade: 'B'}]</code></pre>
</div>
<div class="member">
<h4 class="name" id="unshift">
<a class="href-link" href="#unshift">#</a>
<span class="code-name" id="unshift" style="font-size:30px">
unshift<span class="signature">(…items)</span>
</span>
</h4>
<div class="description">
<p>向集合起始位置添加一个或多个元素</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>items</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要添加的一个或多个元素</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<h5>示例</h5>
<p class="code-caption"><h7 id='toArray'>返回集合对象中元素组成的数组</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.unshift(1, 2)</code></pre>
</div>
</div>
</div>
</article>
</section>
<section>
<article>
<div class="container-overview">
<div class='vertical-section'>
<div class="members">
<div class="member">
<h4 class="name" id="Collection">
<a class="href-link" href="#Collection">#</a>
<span class="code-name" id="Collection" style="font-size:30px">
new Collection<span class="signature">(collection<span class="signature-attributes">opt</span>)</span>
</span>
</h4>
<div class="description">
<p>构造函数</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th style="min-width: 100px;">默认值</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>collection</code></td>
<td class="type">
<span class="param-type">
Array
</span>
</td>
<td class="default">
[]
</td>
<td class="description last"><p>集合中元素的数组</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
</div>
</div>
</div>
</div>
<div class='vertical-section'>
<h3 id='member'>成员变量</h3>
<h4 style="margin-top: 20px;margin-bottom: 20px;">成员变量概述</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code><a href="#items">items</a></code></td>
<td class="name">
<code>
<span class="param-type">
Array.<any>
</span>
</code>
</td>
<td class="name"><code><p>items</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#items">items</a></code></td>
<td class="name">
<code>
<span class="param-type">
Array.<any>
</span>
</code>
</td>
<td class="name"><code><p>items</p></code></td>
</tr>
</tbody>
</table>
</div>
<h4 style="margin-top: 20px;margin-bottom: 20px;">成员变量详情</h4>
<div class="members">
<div class="member">
<span class="method-parameter is-pulled-right">
<label>类型:</label>
<span class="param-type">
Array.<any>
</span>
</span>
<h4 class="name" id="items">
<a class="href-link" href="#items">#</a>
<span class="code-name">
items
</span>
</h4>
<div class="description">
<p>items</p>
</div>
<dl class="details">
</dl>
</div>
<div class="member">
<span class="method-parameter is-pulled-right">
<label>类型:</label>
<span class="param-type">
Array.<any>
</span>
</span>
<h4 class="name" id="items">
<a class="href-link" href="#items">#</a>
<span class='tag'>readonly</span>
<span class="code-name">
items
</span>
</h4>
<div class="description">
<p>items</p>
</div>
<dl class="details">
</dl>
</div>
</div>
</div>
<div class='vertical-section'>
<h3 id='function'>方法</h3>
<h4 style="margin-top: 20px;margin-bottom: 20px;">方法概述</h4>
<div class="members">
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>返回值类型</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code><a href="#isCollection">isCollection</a></code></td>
<td class="name">
<code>
<span class="param-type">
Boolean
</span>
</code>
</td>
<td class="name"><code><p>判断传入的对象是否是一个集合对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#add">add</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>添加一个元素到集合中</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#addMany">addMany</a></code></td>
<td class="name">
<code>
</code>
</td>
<td class="name"><code><p>添加多个元素到集合中,添加完成后会发送数据变更事件</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#all">all</a></code></td>
<td class="name">
<code>
<span class="param-type">
Array.<*>
</span>
</code>
</td>
<td class="name"><code><p>获取集合中的所有元素并返回一个数组</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#at">at</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>返回指定下标处的元素</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#clone">clone</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>克隆并返回一个新集合对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#concat">concat</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>将一个数组或者集合对象链接到当前集合对象末尾</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#createInstance">createInstance</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>创建实例,可由子类重载</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#every">every</a></code></td>
<td class="name">
<code>
<span class="param-type">
Boolean
</span>
</code>
</td>
<td class="name"><code><p>检测数组所有元素是否都符合指定条件(通过函数提供)</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#filter">filter</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>通过一个过滤条件(函数提供)来过滤并返回元素</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#find">find</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>返回第一个符合过滤条件(函数提供)的元素,如果没找到则返回undefined</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#findIndex">findIndex</a></code></td>
<td class="name">
<code>
<span class="param-type">
Number
</span>
</code>
</td>
<td class="name"><code><p>返回第一个符合过滤条件(函数提供)的元素的下标,如果没找到则返回-1</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#flatten">flatten</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>扁平化一个集合对象,通过传入的扁平化函数来指定要扁平化的对象数组,直到指定的对象数组为空或者元素数量为0,之后返回一个新集合对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#forEach">forEach</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>对集合中的所有元素执行传入的函数</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#getItemAt">getItemAt</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>获取指定下标的元素,没找到则返回undefined</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#includes">includes</a></code></td>
<td class="name">
<code>
<span class="param-type">
Boolean
</span>
</code>
</td>
<td class="name"><code><p>判断集合中是否包含该元素</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#indexOf">indexOf</a></code></td>
<td class="name">
<code>
<span class="param-type">
Number
</span>
</code>
</td>
<td class="name"><code><p>返回元素在集合中的下标</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#join">join</a></code></td>
<td class="name">
<code>
<span class="param-type">
String
</span>
</code>
</td>
<td class="name"><code><p>通过传入一个分隔符,将集合中的元素通过分隔符拼接成一个字符串并返回</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#lastIndexOf">lastIndexOf</a></code></td>
<td class="name">
<code>
<span class="param-type">
Number
</span>
</code>
</td>
<td class="name"><code><p>从集合的最末尾开始,寻找该元素,并返回元素下标</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#map">map</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>通过一个遍历函数来遍历该集合下的所有元素,并返回一个新集合对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#pop">pop</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>删除并返回集合的最后一个元素</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#push">push</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>添加一个元素到集合中</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#reduce">reduce</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>接收一个函数做为累加器,将集合中的每一个元素(下标从小到大的顺序)进行累加,最后返回一个对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#reduceRight">reduceRight</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>接收一个函数做为累加器,将集合中的每一个元素(下标从大到小的顺序)进行累加,最后返回一个对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#remove">remove</a></code></td>
<td class="name">
<code>
<span class="param-type">
Boolean
</span>
</code>
</td>
<td class="name"><code><p>删除一个元素,仅会删除找到的第一个元素,并发送删除事件</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#removeAll">removeAll</a></code></td>
<td class="name">
<code>
</code>
</td>
<td class="name"><code><p>删除集合中的所有元素,删除完成后会发送数据变更事件</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#removeAt">removeAt</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>删除指定下标的元素</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#removeMany">removeMany</a></code></td>
<td class="name">
<code>
<span class="param-type">
Array.<*>
</span>
</code>
</td>
<td class="name"><code><p>删除集合中的多个元素,删除完成后会发送数据变更事件</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#reorder">reorder</a></code></td>
<td class="name">
<code>
</code>
</td>
<td class="name"><code><p>将指的元素调整到集合中指的下标位置</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#reverse">reverse</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>将集合对象中的元素反转,并返回新集合对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#shift">shift</a></code></td>
<td class="name">
<code>
<span class="param-type">
*
</span>
</code>
</td>
<td class="name"><code><p>删除并返回集合的第一个元素(元素下标为0)</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#slice">slice</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>截取集合中从start开始到end下标的元素,并返回一个新集合对象</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#some">some</a></code></td>
<td class="name">
<code>
<span class="param-type">
Boolean
</span>
</code>
</td>
<td class="name"><code><p>判断集合对象中的元素是否满足过滤条件,只要有一个元素满足过滤条件,则会返回true,如果都不满足过滤条件,则返回false</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#sort">sort</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>通过一个排序函数来对当前的集合进行排序,之后返回一个新集合对象,参考js的sort函数</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#splice">splice</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>向集合中删除或添加一个元素,参考js的splice方法</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#toArray">toArray</a></code></td>
<td class="name">
<code>
<span class="param-type">
Array
</span>
</code>
</td>
<td class="name"><code><p>返回集合对象中元素组成的数组</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#unique">unique</a></code></td>
<td class="name">
<code>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</code>
</td>
<td class="name"><code><p>去除集合中的重复元素</p></code></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code><a href="#unshift">unshift</a></code></td>
<td class="name">
<code>
</code>
</td>
<td class="name"><code><p>向集合起始位置添加一个或多个元素</p></code></td>
</tr>
</tbody>
</table>
</div>
<h4 style="margin-top: 20px;margin-bottom: 20px;">方法详情</h4>
<div class="member">
<h4 class="name" id=".isCollection">
<a class="href-link" href="#.isCollection">#</a>
<span class='tag'>static</span>
<span class="code-name" id="isCollection" style="font-size:30px">
isCollection<span class="signature">(item)</span>
</span>
</h4>
<div class="description">
<p>判断传入的对象是否是一个集合对象</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要判断的对象</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>是否是集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Boolean
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='isCollection'>判断传入的对象是否是一个集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const isCollection = Collection.isCollection(collection)</code></pre>
</div>
<div class="member">
<h4 class="name" id="add">
<a class="href-link" href="#add">#</a>
<span class="code-name" id="add" style="font-size:30px">
add<span class="signature">(item, index)</span>
</span>
</h4>
<div class="description">
<p>添加一个元素到集合中</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要添加的元素</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>指的元素要添加的位置,如果不指定,默认添加到集合末尾</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>添加完元素后的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='add'>添加一个元素到集合中</h7></p>
<pre class="prettyprint"><code>const collection = new Collection()
collection.add({
key: 'value'
})</code></pre>
<p class="code-caption"><h7 id='add2'>添加一个元素到集合中的指定位置</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.add({
key: 'value'
}, 1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="addMany">
<a class="href-link" href="#addMany">#</a>
<span class="code-name" id="addMany" style="font-size:30px">
addMany<span class="signature">(items, index)</span>
</span>
</h4>
<div class="description">
<p>添加多个元素到集合中,添加完成后会发送数据变更事件</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>items</code></td>
<td class="type">
<span class="param-type">
Array.<*>
</span>
</td>
<td class="description last"><p>要添加的多个元素</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>指的元素要添加的位置,如果不指定,默认添加到集合末尾</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<h5>示例</h5>
<p class="code-caption"><h7 id='addMany'>添加多个元素到集合中</h7></p>
<pre class="prettyprint"><code>const collection = new Collection()
collection.addMany([1, 2, 3])</code></pre>
<p class="code-caption"><h7 id='addMany2'>添加多个元素到集合中的指定位置</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.addMany([1, 2, 3], 2)</code></pre>
</div>
<div class="member">
<h4 class="name" id="all">
<a class="href-link" href="#all">#</a>
<span class="code-name" id="all" style="font-size:30px">
all<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>获取集合中的所有元素并返回一个数组</p>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>集合中元素构成的数组</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Array.<*>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='toArray'>返回集合对象中元素组成的数组</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.all()</code></pre>
</div>
<div class="member">
<h4 class="name" id="at">
<a class="href-link" href="#at">#</a>
<span class="code-name" id="at" style="font-size:30px">
at<span class="signature">(index)</span>
</span>
</h4>
<div class="description">
<p>返回指定下标处的元素</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>元素下标,默认从0开始,允许使用正整数和负整数,负整数从集合中的最后一个元素开始倒数</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>查询到的元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='at'>返回指定下标处的元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const item = collection.at(1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="clone">
<a class="href-link" href="#clone">#</a>
<span class="code-name" id="clone" style="font-size:30px">
clone<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>克隆并返回一个新集合对象</p>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>克隆后的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='clone'>克隆并返回一个新集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const cloneObj = collection.clone()</code></pre>
</div>
<div class="member">
<h4 class="name" id="concat">
<a class="href-link" href="#concat">#</a>
<span class="code-name" id="concat" style="font-size:30px">
concat<span class="signature">(collection)</span>
</span>
</h4>
<div class="description">
<p>将一个数组或者集合对象链接到当前集合对象末尾</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>collection</code></td>
<td class="type">
<span class="param-type">
Array
</span>
|
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</td>
<td class="description last"><p>要链接的数组或者集合对象</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>链接后的新集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='concat'>将一个数组或者集合对象链接到当前集合对象末尾</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.concat([{'a': 1}, {'b': 2}])
collection.concat(new Collection([4, 5, 6]))</code></pre>
</div>
<div class="member">
<h4 class="name" id="createInstance">
<a class="href-link" href="#createInstance">#</a>
<span class="code-name" id="createInstance" style="font-size:30px">
createInstance<span class="signature">(item)</span>
</span>
</h4>
<div class="description">
<p>创建实例,可由子类重载</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要创建的实例对象</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>创建的实例对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
</div>
<div class="member">
<h4 class="name" id="every">
<a class="href-link" href="#every">#</a>
<span class="code-name" id="every" style="font-size:30px">
every<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>检测数组所有元素是否都符合指定条件(通过函数提供)</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>过滤条件</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>是否全部满足过滤条件</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Boolean
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='every'>检测数组所有元素是否都符合指定条件</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const isNumber = collection.every(function(item) {
return typeof item === 'number'
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="filter">
<a class="href-link" href="#filter">#</a>
<span class="code-name" id="filter" style="font-size:30px">
filter<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>通过一个过滤条件(函数提供)来过滤并返回元素</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>过滤条件,如果过滤条件不是函数,则返回undefined</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>过滤后的新集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='filter'>通过一个过滤条件(函数提供)来过滤并返回元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3, 4, 5])
const newCollection = collection.filter(function(item) {
return item > 2
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="find">
<a class="href-link" href="#find">#</a>
<span class="code-name" id="find" style="font-size:30px">
find<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>返回第一个符合过滤条件(函数提供)的元素,如果没找到则返回undefined</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>过滤条件,如果过滤条件不是函数,也返回undefined</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>第一个符合过滤条件的元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='find'>返回第一个符合过滤条件(函数提供)的元素,如果没找到则返回undefined</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3, 4, 5])
const item = collection.find(function(item) {
return item > 2
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="findIndex">
<a class="href-link" href="#findIndex">#</a>
<span class="code-name" id="findIndex" style="font-size:30px">
findIndex<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>返回第一个符合过滤条件(函数提供)的元素的下标,如果没找到则返回-1</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>过滤条件</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>第一个符合过滤条件(函数提供)的元素的下标</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Number
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='findIndex'>返回第一个符合过滤条件(函数提供)的元素的下标,如果没找到则返回-1</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3, 4, 5])
const index = collection.findIndex(function(item) {
return item > 1
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="flatten">
<a class="href-link" href="#flatten">#</a>
<span class="code-name" id="flatten" style="font-size:30px">
flatten<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>扁平化一个集合对象,通过传入的扁平化函数来指定要扁平化的对象数组,直到指定的对象数组为空或者元素数量为0,之后返回一个新集合对象</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>扁平化函数,通过该函数来指定要扁平化的对象数组,如果该函数不是一个函数对象,则返回undefined</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>扁平化后的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='flatten'>扁平化一个集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([{
layers: [1, 2, 3]
},{
items: [4, 5, 6]
}])
const flatten = collection.flatten(function(item) {
return item.layers || item.items
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="forEach">
<a class="href-link" href="#forEach">#</a>
<span class="code-name" id="forEach" style="font-size:30px">
forEach<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>对集合中的所有元素执行传入的函数</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>针对元素的执行函数,参考js数组的forEach方法</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>执行完函数后的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='forEach'>对集合中的所有元素执行传入的函数</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.forEach(function(item) {
console.log("item:", item)
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="getItemAt">
<a class="href-link" href="#getItemAt">#</a>
<span class="code-name" id="getItemAt" style="font-size:30px">
getItemAt<span class="signature">(index)</span>
</span>
</h4>
<div class="description">
<p>获取指定下标的元素,没找到则返回undefined</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>元素下标</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>该下标下的元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='getItemAt'>获取指定下标的元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const item = collection.getItemAt(1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="includes">
<a class="href-link" href="#includes">#</a>
<span class="code-name" id="includes" style="font-size:30px">
includes<span class="signature">(item)</span>
</span>
</h4>
<div class="description">
<p>判断集合中是否包含该元素</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要检查的元素对象</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>集合中是否包含该元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Boolean
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='includes'>判断集合中是否包含该元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const isInclude = collection.includes(2)</code></pre>
</div>
<div class="member">
<h4 class="name" id="indexOf">
<a class="href-link" href="#indexOf">#</a>
<span class="code-name" id="indexOf" style="font-size:30px">
indexOf<span class="signature">(item, fromIndex)</span>
</span>
</h4>
<div class="description">
<p>返回元素在集合中的下标</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要在集合中寻找的元素</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>fromIndex</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>选择起始下标,默认为0,即从何处开始寻找</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>元素在集合中的下标</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Number
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='indexOf'>判断集合中是否包含该元素</h7></p>
<pre class="prettyprint"><code>const item = {
'a': 1
}
const collection = new Collection([item, 2, 3])
const index = collection.indexOf(item)</code></pre>
<p class="code-caption"><h7 id='indexOf2'>判断集合中是否包含该元素-选择起始下标</h7></p>
<pre class="prettyprint"><code>const item = {
'a': 1
}
const collection = new Collection([item, 2, 3, item])
const index = collection.indexOf(item, 1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="join">
<a class="href-link" href="#join">#</a>
<span class="code-name" id="join" style="font-size:30px">
join<span class="signature">(separator)</span>
</span>
</h4>
<div class="description">
<p>通过传入一个分隔符,将集合中的元素通过分隔符拼接成一个字符串并返回</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>separator</code></td>
<td class="type">
<span class="param-type">
String
</span>
</td>
<td class="description last"><p>分割符号</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>拼接完成的字符串</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
String
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='join'>通过传入一个分隔符,将集合中的元素通过分隔符拼接成一个字符串并返回</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const str = collection.join(',')</code></pre>
</div>
<div class="member">
<h4 class="name" id="lastIndexOf">
<a class="href-link" href="#lastIndexOf">#</a>
<span class="code-name" id="lastIndexOf" style="font-size:30px">
lastIndexOf<span class="signature">(item, fromIndex)</span>
</span>
</h4>
<div class="description">
<p>从集合的最末尾开始,寻找该元素,并返回元素下标</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要寻找的元素</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>fromIndex</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>从何处开始查找,默认为集合的长度-1</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>第一个找到的元素下标,未找到则返回-1</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Number
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='lastIndexOf'>从集合的最末尾开始,寻找该元素,并返回元素下标</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const index = collection.lastIndexOf(3)</code></pre>
<p class="code-caption"><h7 id='lastIndexOf2'>从集合的最末尾开始,寻找该元素,并返回元素下标 - 指定起始额位置</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3, 3, 3])
const index = collection.lastIndexOf(3, 3)</code></pre>
</div>
<div class="member">
<h4 class="name" id="map">
<a class="href-link" href="#map">#</a>
<span class="code-name" id="map" style="font-size:30px">
map<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>通过一个遍历函数来遍历该集合下的所有元素,并返回一个新集合对象</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>遍历函数</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>遍历后的新集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='map'>通过一个遍历函数来遍历该集合下的所有元素,并返回一个新集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const newCollection = collection.map(function (item) {
return item + 1
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="pop">
<a class="href-link" href="#pop">#</a>
<span class="code-name" id="pop" style="font-size:30px">
pop<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>删除并返回集合的最后一个元素</p>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>集合的最后一个元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='pop'>删除并返回集合的最后一个元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const item = collection.pop()</code></pre>
</div>
<div class="member">
<h4 class="name" id="push">
<a class="href-link" href="#push">#</a>
<span class="code-name" id="push" style="font-size:30px">
push<span class="signature">(item)</span>
</span>
</h4>
<div class="description">
<p>添加一个元素到集合中</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要添加的元素</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>添加完元素后的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='push'>添加一个元素到集合中</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.push(4)</code></pre>
</div>
<div class="member">
<h4 class="name" id="reduce">
<a class="href-link" href="#reduce">#</a>
<span class="code-name" id="reduce" style="font-size:30px">
reduce<span class="signature">(fn, baseValue)</span>
</span>
</h4>
<div class="description">
<p>接收一个函数做为累加器,将集合中的每一个元素(下标从小到大的顺序)进行累加,最后返回一个对象</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>累加器函数</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>baseValue</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>累加的基础对象</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>累加后的对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='reduce'>接收一个函数做为累加器,将集合中的每一个元素(下标从小到大的顺序)进行累加,最后返回一个对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const sum = collection.reduce(function (reduceCarry, item) {
return reduceCarry += item
}, 0)</code></pre>
</div>
<div class="member">
<h4 class="name" id="reduceRight">
<a class="href-link" href="#reduceRight">#</a>
<span class="code-name" id="reduceRight" style="font-size:30px">
reduceRight<span class="signature">(fn, baseValue)</span>
</span>
</h4>
<div class="description">
<p>接收一个函数做为累加器,将集合中的每一个元素(下标从大到小的顺序)进行累加,最后返回一个对象</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>累加器函数</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>baseValue</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>累加的基础对象</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>累加后的对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='reduceRight'>接收一个函数做为累加器,将集合中的每一个元素(下标从大到小的顺序)进行累加,最后返回一个对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const sum = collection.reduce(function (reduceCarry, item) {
console.log(item)
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="remove">
<a class="href-link" href="#remove">#</a>
<span class="code-name" id="remove" style="font-size:30px">
remove<span class="signature">(item)</span>
</span>
</h4>
<div class="description">
<p>删除一个元素,仅会删除找到的第一个元素,并发送删除事件</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要删除的元素</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>元素是否删除成功</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Boolean
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='remove'>删除一个元素,仅会删除找到的第一个元素,并发送删除事件</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.remove(1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="removeAll">
<a class="href-link" href="#removeAll">#</a>
<span class="code-name" id="removeAll" style="font-size:30px">
removeAll<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>删除集合中的所有元素,删除完成后会发送数据变更事件</p>
</div>
<dl class="details">
</dl>
<h5>示例</h5>
<p class="code-caption"><h7 id='removeAll'>删除集合中的所有元素,删除完成后会发送数据变更事件</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.removeAll(1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="removeAt">
<a class="href-link" href="#removeAt">#</a>
<span class="code-name" id="removeAt" style="font-size:30px">
removeAt<span class="signature">(index)</span>
</span>
</h4>
<div class="description">
<p>删除指定下标的元素</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>元素的下标,从0开始</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>删除后的元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='removeAt'>删除指定下标的元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.removeAt(1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="removeMany">
<a class="href-link" href="#removeMany">#</a>
<span class="code-name" id="removeMany" style="font-size:30px">
removeMany<span class="signature">(items)</span>
</span>
</h4>
<div class="description">
<p>删除集合中的多个元素,删除完成后会发送数据变更事件</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>items</code></td>
<td class="type">
<span class="param-type">
Array.<*>
</span>
</td>
<td class="description last"><p>要添加的多个元素</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>被删除的元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Array.<*>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='removeMany'>删除集合中的多个元素,删除完成后会发送数据变更事件</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.removeMany([1, 2])</code></pre>
</div>
<div class="member">
<h4 class="name" id="reorder">
<a class="href-link" href="#reorder">#</a>
<span class="code-name" id="reorder" style="font-size:30px">
reorder<span class="signature">(item, index)</span>
</span>
</h4>
<div class="description">
<p>将指的元素调整到集合中指的下标位置</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要排序的元素</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>元素要调整到的位置</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<h5>示例</h5>
<p class="code-caption"><h7 id='reorder'>将指的元素调整到集合中指的下标位置</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.reorder(1, 2)</code></pre>
</div>
<div class="member">
<h4 class="name" id="reverse">
<a class="href-link" href="#reverse">#</a>
<span class="code-name" id="reverse" style="font-size:30px">
reverse<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>将集合对象中的元素反转,并返回新集合对象</p>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>新的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='reverse'>将集合对象中的元素反转,并返回新集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const newCollection = collection.reverse()</code></pre>
</div>
<div class="member">
<h4 class="name" id="shift">
<a class="href-link" href="#shift">#</a>
<span class="code-name" id="shift" style="font-size:30px">
shift<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>删除并返回集合的第一个元素(元素下标为0)</p>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>集合的第一个元素</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
*
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='reverse'>删除并返回集合的第一个元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const item = collection.shift()</code></pre>
</div>
<div class="member">
<h4 class="name" id="slice">
<a class="href-link" href="#slice">#</a>
<span class="code-name" id="slice" style="font-size:30px">
slice<span class="signature">(start, end)</span>
</span>
</h4>
<div class="description">
<p>截取集合中从start开始到end下标的元素,并返回一个新集合对象</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>从0开始的元素小标</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>end</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>截至的元素下标,不填则默认到集合最后一个元素</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>新集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='slice'>截取集合中从start开始到end下标的元素,并返回一个新集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3, 4, 5])
const newCollection = collection.slice(1, 3)</code></pre>
</div>
<div class="member">
<h4 class="name" id="some">
<a class="href-link" href="#some">#</a>
<span class="code-name" id="some" style="font-size:30px">
some<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>判断集合对象中的元素是否满足过滤条件,只要有一个元素满足过滤条件,则会返回true,如果都不满足过滤条件,则返回false</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>过滤条件,如果过滤条件不是函数,也返回false</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>是否满足过滤条件</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Boolean
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='some'>判断集合对象中的元素是否满足过滤条件</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3, 4, 5])
const flag = collection.some(function (item) {
return item === 1
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="sort">
<a class="href-link" href="#sort">#</a>
<span class="code-name" id="sort" style="font-size:30px">
sort<span class="signature">(fn)</span>
</span>
</h4>
<div class="description">
<p>通过一个排序函数来对当前的集合进行排序,之后返回一个新集合对象,参考js的sort函数</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">
function
</span>
</td>
<td class="description last"><p>排序函数,不填则默认按从小到达排序</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>新的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='sort'>通过一个排序函数来对当前的集合进行排序,之后返回一个新集合对象</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([{
'a': 2
},{
'a': 1
},{
'a': 3
}])
const newCollection = collection.sort(function (itemA, itemB) {
return itemA.a - itemB.a
})</code></pre>
</div>
<div class="member">
<h4 class="name" id="splice">
<a class="href-link" href="#splice">#</a>
<span class="code-name" id="splice" style="font-size:30px">
splice<span class="signature">(start, deleteCount, …items)</span>
</span>
</h4>
<div class="description">
<p>向集合中删除或添加一个元素,参考js的splice方法</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>删除或添加的起始下标</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>deleteCount</code></td>
<td class="type">
<span class="param-type">
Number
</span>
</td>
<td class="description last"><p>删除或添加的数量</p></td>
</tr>
<tr class="deep-level-0">
<td class="name"><code>items</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要删除或添加的元素</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>新的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='splice'>向集合中删除一个元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
const newCollection = collection.splice(1, 1)</code></pre>
<p class="code-caption"><h7 id='splice2'>向集合中添加一个元素</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.splice(1, 0, 1)</code></pre>
</div>
<div class="member">
<h4 class="name" id="toArray">
<a class="href-link" href="#toArray">#</a>
<span class="code-name" id="toArray" style="font-size:30px">
toArray<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>返回集合对象中元素组成的数组</p>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>集合对象中元素组成的数组</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
Array
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption"><h7 id='toArray'>返回集合对象中元素组成的数组</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.toArray()</code></pre>
</div>
<div class="member">
<h4 class="name" id="unique">
<a class="href-link" href="#unique">#</a>
<span class="code-name" id="unique" style="font-size:30px">
unique<span class="signature">(key)</span>
</span>
</h4>
<div class="description">
<p>去除集合中的重复元素</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">
function
</span>
|
<span class="param-type">
String
</span>
</td>
<td class="description last"><p>指定一个去重函数或者要素的去重字段</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<div class='columns method-parameter'>
<div class="column is-2"><label>返回值</label></div>
<div class="column is-10">
<div class="columns">
<div class='param-desc column is-7'><p>去重后的集合对象</p></div>
<div class='column is-5 has-text-left'>
<label>类型: </label>
<span class="param-type">
<a link="Collection.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="Collection" Collection.html>Collection</a>
</span>
</div>
</div>
</div>
</div>
<h5>示例</h5>
<p class="code-caption">No Arguments</p>
<pre class="prettyprint"><code>const unique = new Collection([2, 1, 2, 3, 3, 4, 5, 1, 2]).unique();
console.log(unique); // [2, 1, 3, 4, 5]</code></pre>
<p class="code-caption">Property Name</p>
<pre class="prettyprint"><code>const students = new Collection([
{ name: 'Rick', grade: 'A'},
{ name: 'Mick', grade: 'B'},
{ name: 'Richard', grade: 'A'},
]);
// Students with unique grades.
students.unique('grade'); // [{ name: 'Rick', grade: 'A'}, { name: 'Mick', grade: 'B'}]</code></pre>
<p class="code-caption">With Callback</p>
<pre class="prettyprint"><code>const students = new Collection([
{ name: 'Rick', grade: 'A'},
{ name: 'Mick', grade: 'B'},
{ name: 'Richard', grade: 'A'},
]);
// Students with unique grades.
students.unique(s => s.grade); // [{ name: 'Rick', grade: 'A'}, { name: 'Mick', grade: 'B'}]</code></pre>
</div>
<div class="member">
<h4 class="name" id="unshift">
<a class="href-link" href="#unshift">#</a>
<span class="code-name" id="unshift" style="font-size:30px">
unshift<span class="signature">(…items)</span>
</span>
</h4>
<div class="description">
<p>向集合起始位置添加一个或多个元素</p>
</div>
<h4>参数</h4>
<div class="table-container">
<table class="params table">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th class="last">描述</th>
</tr>
</thead>
<tbody>
<tr class="deep-level-0">
<td class="name"><code>items</code></td>
<td class="type">
<span class="param-type">
*
</span>
</td>
<td class="description last"><p>要添加的一个或多个元素</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="details">
</dl>
<h5>示例</h5>
<p class="code-caption"><h7 id='toArray'>返回集合对象中元素组成的数组</h7></p>
<pre class="prettyprint"><code>const collection = new Collection([1, 2, 3])
collection.unshift(1, 2)</code></pre>
</div>
</div>
</div>
</article>
</section>