未验证 提交 1e05ec2e 编写于 作者: K king_he 提交者: Gitee

update en/application-dev/reference/apis/js-apis-vector.md.

Signed-off-by: Nking_he <6384784@qq.com>
上级 38a82978
# Linear Container Vector # Linear Container Vector
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -20,9 +20,9 @@ SystemCapability.Utils.Lang ...@@ -20,9 +20,9 @@ SystemCapability.Utils.Lang
### Attributes ### Attributes
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| length | number | Yes| No| Number of entries in a vector (called container later).| | length | number | Yes | No | Number of entries in a vector (called container later). |
### constructor ### constructor
...@@ -46,15 +46,15 @@ Adds an entry at the end of this container. ...@@ -46,15 +46,15 @@ Adds an entry at the end of this container.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| element | T | Yes| Entry to add.| | element | T | Yes | Entry to add. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| | boolean | Returns **true** if the entry is added successfully; returns **false** otherwise. |
**Example** **Example**
...@@ -76,10 +76,10 @@ Inserts an entry at the specified position in this container. ...@@ -76,10 +76,10 @@ Inserts an entry at the specified position in this container.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| element | T | Yes| Entry to insert.| | element | T | Yes | Entry to insert. |
| index | number | Yes| Index of the position where the entry is to be inserted.| | index | number | Yes | Index of the position where the entry is to be inserted. |
**Example** **Example**
...@@ -98,15 +98,15 @@ Checks whether this container has the specified entry. ...@@ -98,15 +98,15 @@ Checks whether this container has the specified entry.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| element | T | Yes| Entry to check.| | element | T | Yes | Entry to check. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the entry is contained; returns **false** otherwise.| | boolean | Returns **true** if the entry is contained; returns **false** otherwise. |
**Example** **Example**
...@@ -125,15 +125,15 @@ Obtains the index of the first occurrence of the specified entry in this contain ...@@ -125,15 +125,15 @@ Obtains the index of the first occurrence of the specified entry in this contain
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| element | T | Yes| Entry to obtain.| | element | T | Yes | Entry to obtain. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| | number | Returns the position index if obtained; returns **-1** if the specified entry is not found. |
**Example** **Example**
...@@ -157,15 +157,15 @@ Obtains the index of the last occurrence of the specified entry in this containe ...@@ -157,15 +157,15 @@ Obtains the index of the last occurrence of the specified entry in this containe
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| element | T | Yes| Entry to obtain.| | element | T | Yes | Entry to obtain. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| | number | Returns the position index if obtained; returns **-1** if the specified entry is not found. |
**Example** **Example**
...@@ -189,15 +189,15 @@ Removes an entry at the specified position from this container. ...@@ -189,15 +189,15 @@ Removes an entry at the specified position from this container.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| index | number | Yes| Position index of the entry to remove.| | index | number | Yes | Position index of the entry to remove. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| T | Entry removed.| | T | Entry removed. |
**Example** **Example**
...@@ -219,15 +219,15 @@ Removes the first occurrence of the specified entry from this container. ...@@ -219,15 +219,15 @@ Removes the first occurrence of the specified entry from this container.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| element | T | Yes| Entry to remove.| | element | T | Yes | Entry to remove. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.| | boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise. |
**Return value** **Return value**
...@@ -248,10 +248,10 @@ Removes from this container all of the entries within a range, including the ent ...@@ -248,10 +248,10 @@ Removes from this container all of the entries within a range, including the ent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| fromIndex | number | Yes| Index of the start position.| | fromIndex | number | Yes | Index of the start position. |
| toIndex | number | Yes| Index of the end position.| | toIndex | number | Yes | Index of the end position. |
**Example** **Example**
...@@ -275,18 +275,18 @@ Replaces all entries in this container with new entries, and returns the new one ...@@ -275,18 +275,18 @@ Replaces all entries in this container with new entries, and returns the new one
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked for replacement.| | callbackfn | function | Yes | Callback invoked for replacement. |
| thisArg | Object | No| Value to use when the callback is invoked.| | thisArg | Object | No | Value to use when the callback is invoked. |
callbackfn callbackfn
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the entry that is currently traversed.| | value | T | Yes | Value of the entry that is currently traversed. |
| index | number | No| Position index of the entry that is currently traversed.| | index | number | No | Position index of the entry that is currently traversed. |
| vector | Vector&lt;T&gt; | No| Instance that invokes the **replaceAllElements** API.| | vector | Vector&lt;T&gt; | No | Instance that invokes the **replaceAllElements** API. |
**Example** **Example**
...@@ -313,18 +313,18 @@ Uses a callback to traverse the entries in this container and obtain their posit ...@@ -313,18 +313,18 @@ Uses a callback to traverse the entries in this container and obtain their posit
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked for replacement.| | callbackfn | function | Yes | Callback invoked for replacement. |
| thisArg | Object | No| Value to use when the callback is invoked.| | thisArg | Object | No | Value to use when the callback is invoked. |
callbackfn callbackfn
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the entry that is currently traversed.| | value | T | Yes | Value of the entry that is currently traversed. |
| index | number | No| Position index of the entry that is currently traversed.| | index | number | No | Position index of the entry that is currently traversed. |
| vector | Vector&lt;T&gt; | No| Instance that invokes the **forEach** API.| | vector | Vector&lt;T&gt; | No | Instance that invokes the **forEach** API. |
**Example** **Example**
...@@ -348,16 +348,16 @@ Sorts entries in this container. ...@@ -348,16 +348,16 @@ Sorts entries in this container.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| comparator | function | No | Callback invoked for sorting. | | comparator | function | No | Callback invoked for sorting. |
comparator comparator
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| firstValue | T | Yes | Previous entry. | | firstValue | T | Yes | Previous entry. |
| secondValue | T | Yes | Next entry. | | secondValue | T | Yes | Next entry. |
**Example** **Example**
...@@ -380,16 +380,16 @@ Obtains entries within a range in this container, including the entry at the sta ...@@ -380,16 +380,16 @@ Obtains entries within a range in this container, including the entry at the sta
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| fromIndex | number | Yes| Index of the start position.| | fromIndex | number | Yes | Index of the start position. |
| toIndex | number | Yes| Index of the end position.| | toIndex | number | Yes | Index of the end position. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| Vector&lt;T&gt; | New **Vector** instance obtained.| | Vector&lt;T&gt; | New **Vector** instance obtained. |
**Return value** **Return value**
...@@ -430,9 +430,9 @@ Clones this container and returns a copy. The modification to the copy does not ...@@ -430,9 +430,9 @@ Clones this container and returns a copy. The modification to the copy does not
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| Vector&lt;T&gt; | New **Vector** instance obtained.| | Vector&lt;T&gt; | New **Vector** instance obtained. |
**Example** **Example**
...@@ -453,9 +453,9 @@ Obtains the capacity of this container. ...@@ -453,9 +453,9 @@ Obtains the capacity of this container.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| number | Capacity obtained.| | number | Capacity obtained. |
**Example** **Example**
...@@ -476,9 +476,9 @@ Converts this container into an array. ...@@ -476,9 +476,9 @@ Converts this container into an array.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| Array&lt;T&gt; | Array obtained.| | Array&lt;T&gt; | Array obtained. |
**Example** **Example**
...@@ -499,9 +499,9 @@ Checks whether this container is empty (contains no entries). ...@@ -499,9 +499,9 @@ Checks whether this container is empty (contains no entries).
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the container is empty; returns **false** otherwise.| | boolean | Returns **true** if the container is empty; returns **false** otherwise. |
**Example** **Example**
...@@ -522,9 +522,9 @@ Increases the capacity of this container. ...@@ -522,9 +522,9 @@ Increases the capacity of this container.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| newCapacity | number | Yes| New capacity.| | newCapacity | number | Yes | New capacity. |
**Example** **Example**
...@@ -563,9 +563,9 @@ Uses commas (,) to concatenate entries in this container into a string. ...@@ -563,9 +563,9 @@ Uses commas (,) to concatenate entries in this container into a string.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| string | String obtained.| | string | String obtained. |
**Example** **Example**
...@@ -586,9 +586,9 @@ Copies entries in this container into an array to overwrite elements of the same ...@@ -586,9 +586,9 @@ Copies entries in this container into an array to overwrite elements of the same
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| array | Array&lt;T&gt; | Yes| Array to which the entries in the container will be copied.| | array | Array&lt;T&gt; | Yes | Array to which the entries in the container will be copied. |
**Example** **Example**
...@@ -610,9 +610,9 @@ Obtains the first entry in this container. ...@@ -610,9 +610,9 @@ Obtains the first entry in this container.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| T | The first entry obtained.| | T | The first entry obtained. |
**Example** **Example**
...@@ -633,9 +633,9 @@ Obtains the last entry in this container. ...@@ -633,9 +633,9 @@ Obtains the last entry in this container.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| T | The last entry obtained.| | T | The last entry obtained. |
**Example** **Example**
...@@ -656,16 +656,16 @@ Searches for an entry backward from the specified position index and returns the ...@@ -656,16 +656,16 @@ Searches for an entry backward from the specified position index and returns the
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| element | T | Yes| Entry to query.| | element | T | Yes | Entry to query. |
| index | number | Yes| Position index where the search starts.| | index | number | Yes | Position index where the search starts. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| number | Returns the position index if obtained; returns **-1** if the entry is not found.| | number | Returns the position index if obtained; returns **-1** if the entry is not found. |
**Example** **Example**
...@@ -687,16 +687,16 @@ Searches for an entry forward from the specified position index and returns the ...@@ -687,16 +687,16 @@ Searches for an entry forward from the specified position index and returns the
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| element | T | Yes| Entry to query.| | element | T | Yes | Entry to query. |
| index | number | Yes| Position index where the search starts.| | index | number | Yes | Position index where the search starts. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| number | Returns the position index if obtained; returns **-1** if the entry is not found.| | number | Returns the position index if obtained; returns **-1** if the entry is not found. |
**Example** **Example**
...@@ -718,9 +718,9 @@ Sets a new length for this container. ...@@ -718,9 +718,9 @@ Sets a new length for this container.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| newSize | number | Yes| New length to set.| | newSize | number | Yes | New length to set. |
**Example** **Example**
...@@ -742,15 +742,15 @@ Obtains an entry at the specified position in this container. ...@@ -742,15 +742,15 @@ Obtains an entry at the specified position in this container.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| index | number | Yes| Position index of the entry to obtain.| | index | number | Yes | Position index of the entry to obtain. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| T | Entry obtained.| | T | Entry obtained. |
**Example** **Example**
...@@ -770,16 +770,16 @@ Replaces an entry at the specified position in this container with a given entry ...@@ -770,16 +770,16 @@ Replaces an entry at the specified position in this container with a given entry
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| index | number | Yes| Position index of the entry to replace.| | index | number | Yes | Position index of the entry to replace. |
| element | T | Yes| Entry to be used for replacement.| | element | T | Yes | Entry to be used for replacement. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| T | New entry.| | T | New entry. |
**Example** **Example**
...@@ -800,9 +800,9 @@ Replaces an entry at the specified position in this container with a given entry ...@@ -800,9 +800,9 @@ Replaces an entry at the specified position in this container with a given entry
Obtains an iterator. Each item of the iterator is a JavaScript object. Obtains an iterator. Each item of the iterator is a JavaScript object.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| IterableIterator&lt;T&gt; | Iterator obtained.| | IterableIterator&lt;T&gt; | Iterator obtained. |
**Example** **Example**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册