> 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.
**ArrayList** is a linear data structure that is implemented based on arrays. **ArrayList** can dynamically adjust the capacity based on project requirements. It increases the capacity by 50% each time.
...
...
@@ -42,7 +41,7 @@ A constructor used to create an **ArrayList** instance.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -77,7 +76,7 @@ Adds an element at the end of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -113,12 +112,12 @@ Inserts an element at the specified position in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The insert method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of index is out of range. |
**Example**
...
...
@@ -151,7 +150,7 @@ Checks whether this container has the specified element.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -188,7 +187,7 @@ Obtains the index of the first occurrence of the specified element in this conta
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -230,7 +229,7 @@ Obtains the index of the last occurrence of the specified element in this contai
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -272,12 +271,12 @@ Removes an element with the specified position from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeByIndex method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of index is out of range. |
**Example**
...
...
@@ -313,7 +312,7 @@ Removes the first occurrence of the specified element from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -347,12 +346,12 @@ Removes from this container all of the elements within a range, including the el
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeByRange method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of fromIndex or toIndex is out of range. |
**Example**
...
...
@@ -391,7 +390,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -426,7 +425,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked for the replacement.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
...
...
@@ -439,7 +438,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -481,7 +480,7 @@ comparator
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -523,12 +522,12 @@ Obtains elements within a range in this container, including the element at the
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The subArrayList method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of fromIndex or toIndex is out of range. |
**Example**
...
...
@@ -553,7 +552,7 @@ Clears this container and sets its length to **0**.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -587,7 +586,7 @@ Clones this container and returns a copy. The modification to the copy does not
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -620,7 +619,7 @@ Obtains the capacity of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -653,7 +652,7 @@ Converts this container into an array.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -686,7 +685,7 @@ Checks whether this container is empty (contains no element).
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -719,7 +718,7 @@ Increases the capacity of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -747,7 +746,7 @@ Trims the capacity of this container to its current length.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -780,7 +779,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
> 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.
Double-ended queue (deque) is a sequence container implemented based on the queue data structure that follows the principles of First In First Out (FIFO) and Last In First Out (LIFO). It allows insertion and removal of elements at both the ends. **Deque** can dynamically adjust the capacity based on project requirements. It doubles the capacity each time. **Deque** differs from **[Queue](js-apis-queue.md)** and **[Vector](js-apis-vector.md)** mainly in the following aspects:
...
...
@@ -41,7 +40,7 @@ A constructor used to create a **Deque** instance.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -69,7 +68,7 @@ Inserts an element at the front of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -104,7 +103,7 @@ Inserts an element at the end of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -145,7 +144,7 @@ Checks whether this container has the specified element.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -172,11 +171,11 @@ Removes the first element of this container.
| Type| Description|
| -------- | -------- |
| T | Element removed.|
| T | First element removed.|
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -206,11 +205,11 @@ Removes the last element of this container.
| Type| Description|
| -------- | -------- |
| T | Element removed.|
| T | Last element removed.|
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -254,7 +253,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -289,7 +288,7 @@ Obtains the first element of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -322,7 +321,7 @@ Obtains the last element of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -355,7 +354,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
> 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.
**HashMap** is a map implemented based on the array, linked list, and red-black tree. It provides efficient data query, insertion, and removal. The elements in a **HashMap** instance are mappings of key-value pairs. Each key must be unique and have only one value.
...
...
@@ -43,7 +42,7 @@ A constructor used to create a **HashMap** instance.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -72,7 +71,7 @@ Checks whether this container is empty (contains no element).
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -108,7 +107,7 @@ Checks whether this container contains the specified key.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -146,7 +145,7 @@ Checks whether this container contains the specified value.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -184,7 +183,7 @@ Obtains the value of the specified key in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -216,7 +215,7 @@ Adds all elements in a **HashMap** instance to this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -256,7 +255,7 @@ Adds an element to this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -292,7 +291,7 @@ Removes an element with the specified key from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -318,7 +317,7 @@ Clears this container and sets its length to **0**.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -350,7 +349,7 @@ Obtains an iterator that contains all the elements in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -387,7 +386,7 @@ Obtains an iterator that contains all the values in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -431,7 +430,7 @@ Replaces an element in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -470,7 +469,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -504,7 +503,7 @@ Obtains an iterator that contains all the elements in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -542,14 +541,13 @@ Obtains an iterator, each item of which is a JavaScript object.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
> 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.
**HashSet** is implemented based on [HashMap](js-apis-hashmap.md). In **HashSet**, only the **value** object is processed.
...
...
@@ -51,7 +50,7 @@ A constructor used to create a **HashSet** instance.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -80,7 +79,7 @@ Checks whether this container is empty (contains no element).
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -116,7 +115,7 @@ Checks whether this container contains the specified element.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -154,7 +153,7 @@ Adds an element to this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -190,7 +189,7 @@ Removes an element from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -216,7 +215,7 @@ Clears this container and sets its length to **0**.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -248,7 +247,7 @@ Obtains an iterator that contains all the values in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -293,7 +292,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -326,7 +325,7 @@ Obtains an iterator that contains all the elements in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -364,7 +363,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
> 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.
**LightWeightMap** stores key-value (KV) pairs. Each key must be unique and have only one value.
**LightWeightMap** is based on generics and uses a lightweight structure. Keys in the map are searched using hash values, which are stored in an array.
**LightWeightMap** is based on generics and uses a lightweight structure. Its default initial capacity is 8, and it has the capacity doubled in each expansion.
The keys in such a set are searched using hash values, which are stored in an array.
Compared with **[HashMap](js-apis-hashmap.md)**, which can also store KV pairs, **LightWeightMap** occupies less memory.
...
...
@@ -44,7 +45,7 @@ A constructor used to create a **LightWeightMap** instance.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -73,7 +74,7 @@ Checks whether this container is empty (contains no element).
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -109,7 +110,7 @@ Checks whether this container contains all elements of the specified **LightWeig
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -149,7 +150,7 @@ Checks whether this container contains the specified key.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -159,10 +160,8 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
letlightWeightMap=newLightWeightMap();
letresult=lightWeightMap.hasKey;
lightWeightMap.hasKey("squirrel");
lightWeightMap.set("squirrel",123);
letresult1=lightWeightMap.hasKey("squirrel");
letresult=lightWeightMap.hasKey("squirrel");
```
...
...
@@ -188,7 +187,7 @@ Checks whether this container contains the specified value.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -214,7 +213,7 @@ Increases the capacity of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -256,7 +255,7 @@ Obtains the value of the specified key in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -294,7 +293,7 @@ Obtains the index of the first occurrence of an element with the specified key i
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -332,7 +331,7 @@ Obtains the index of the first occurrence of an element with the specified value
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -370,12 +369,12 @@ Obtains the key of an element at the specified position in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The getKeyAt method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of index is out of range. |
**Example**
...
...
@@ -403,7 +402,7 @@ Adds all elements in a **LightWeightMap** instance to this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -416,7 +415,7 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel",123);
lightWeightMap.set("sparrow",356);
letmap=newLightWeightMap();
lightWeightMap.setAll(map);
map.setAll(lightWeightMap);// Add all elements in lightWeightMap to the map.
```
...
...
@@ -442,7 +441,7 @@ Adds an element to this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -478,7 +477,7 @@ Removes an element with the specified key from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -516,7 +515,7 @@ Removes an element at the specified position from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -555,12 +554,12 @@ Sets a value for an element at the specified position in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The setValueAt method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of index is out of range. |
**Example**
...
...
@@ -594,12 +593,12 @@ Obtains the value of an element at the specified position in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The getValueAt method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of index is out of range. |
**Example**
...
...
@@ -621,7 +620,7 @@ Clears this container and sets its length to **0**.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -653,7 +652,7 @@ Obtains an iterator that contains all the keys in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -690,7 +689,7 @@ Obtains an iterator that contains all the values in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -735,7 +734,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -769,7 +768,7 @@ Obtains an iterator that contains all the elements in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -800,13 +799,13 @@ Concatenates the elements in this container into a string and returns the string
**Return value**
| Type| Description|
| -------- | -------- |
| String | String obtained.|
| Type| Description|
| -------- | -------- |
| String | String obtained.|
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -818,7 +817,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
letlightWeightMap=newLightWeightMap();
lightWeightMap.set("squirrel",123);
lightWeightMap.set("sparrow",356);
letiter=lightWeightMap.toString();
letresult=lightWeightMap.toString();
```
### [Symbol.iterator]
...
...
@@ -837,7 +836,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
> 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.
**LightWeightSet** stores a set of values, each of which must be unique.
...
...
@@ -44,7 +43,7 @@ A constructor used to create a **LightWeightSet** instance.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -73,7 +72,7 @@ Checks whether this container is empty (contains no element).
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -108,7 +107,7 @@ Adds an element to this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -138,7 +137,7 @@ Adds all elements in a **LightWeightSet** instance to this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -178,7 +177,7 @@ Checks whether this container contains all elements of the specified **LightWeig
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -218,7 +217,7 @@ Checks whether this container has the specified key.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -246,7 +245,7 @@ Checks whether this container contains objects of the same type as the specified
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| obj | Object | Yes| Object to be used for comparison.|
| obj | Object | Yes| **LightWeightSet** instance to be used for comparison.|
**Return value**
...
...
@@ -256,7 +255,7 @@ Checks whether this container contains objects of the same type as the specified
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -289,12 +288,12 @@ Increases the capacity of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The increaseCapacityTo method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of minimumCapacity is out of range. |
**Example**
...
...
@@ -326,7 +325,7 @@ Obtains the position index of the element with the specified key in this contain
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -364,7 +363,7 @@ Removes an element of the specified key from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -402,7 +401,7 @@ Removes the element at the specified position from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -440,7 +439,7 @@ Obtains the value of the element at the specified position in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -466,7 +465,7 @@ Clears this container and sets its length to **0**.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -496,14 +495,6 @@ Obtains a string that contains all elements in this container.
| -------- | -------- |
| String | String obtained.|
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The toString method cannot be bound. |
**Example**
```ts
...
...
@@ -530,7 +521,7 @@ Obtains an array that contains all objects in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -562,7 +553,7 @@ Obtains an iterator that contains all the values in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -607,7 +598,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -641,7 +632,7 @@ Obtains an iterator that contains all the elements in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -678,7 +669,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
> 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.
**LinkedList** is implemented based on the doubly linked list. Each node of the doubly linked list has references pointing to the previous element and the next element. When querying an element, the system traverses the list from the beginning or end. **LinkedList** offers efficient insertion and removal operations but supports low query efficiency. **LinkedList** allows null elements.
Unlike **[List](js-apis-list.md)**, which is a singly linked list, **LinkedList** is a doubly linked list that supports insertion and removal at both ends.
**LinkedList** is less efficient in data access than **[ArrayList](js-apis-arraylist.md)**.
**LinkedList** is more efficient in data insertion than **[ArrayList](js-apis-arraylist.md)**, but less efficient in data access.
**Recommended use case**: Use **LinkedList** for frequent insertion and removal operations.
...
...
@@ -42,7 +41,7 @@ A constructor used to create a **LinkedList** instance.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -78,7 +77,7 @@ Adds an element at the end of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -113,7 +112,7 @@ Adds an element at the top of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -149,12 +148,12 @@ Inserts an element at the specified position in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The insert method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of index is out of range. |
**Example**
...
...
@@ -187,7 +186,7 @@ Checks whether this container has the specified element.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -224,7 +223,7 @@ Obtains an element at the specified position in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -266,7 +265,7 @@ Obtains the index of the last occurrence of the specified element in this contai
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -308,7 +307,7 @@ Obtains the index of the first occurrence of the specified element in this conta
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -350,12 +349,12 @@ Removes an element at the specified position from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeByIndex method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of index is out of range. |
**Example**
...
...
@@ -385,7 +384,7 @@ Removes the first element from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -420,7 +419,7 @@ Removes the last element from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -461,7 +460,7 @@ Removes the first occurrence of the specified element from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -500,7 +499,7 @@ Removes the first occurrence of the specified element from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -540,7 +539,7 @@ Removes the last occurrence of the specified element from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -574,7 +573,7 @@ Clones this container and returns a copy. The modification to the copy does not
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -617,7 +616,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -646,7 +645,7 @@ Clears this container and sets its length to **0**.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -686,12 +685,12 @@ Replaces an element at the specified position in this container with a given ele
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The set method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of index is out of range. |
**Example**
...
...
@@ -720,7 +719,7 @@ Converts this container into an array.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -752,7 +751,7 @@ Obtains the first element in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -785,7 +784,7 @@ Obtains the last element in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -818,7 +817,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
> 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.
**List** is implemented based on the singly linked list. Each node has a reference pointing to the next element. When querying an element, the system traverses the list from the beginning. **List** offers efficient insertion and removal operations but supports low query efficiency. **List** allows null elements.
...
...
@@ -16,7 +15,7 @@ This topic uses the following to identify the use of generics:
## Modules to Import
```ts
importListfrom'@ohos.util.List';
importListfrom'@ohos.util.List';
```
...
...
@@ -26,7 +25,7 @@ import List from '@ohos.util.List';
> 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.
**PlainArray** stores key-value (KV) pairs. Each key must be unique, be of the number type, and have only one value.
...
...
@@ -21,6 +20,8 @@ This topic uses the following to identify the use of generics:
importPlainArrayfrom'@ohos.util.PlainArray';
```
## PlainArray
### Attributes
...
...
@@ -42,7 +43,7 @@ A constructor used to create a **PlainArray** instance.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -71,7 +72,7 @@ Checks whether this container is empty.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -107,7 +108,7 @@ Checks whether this container contains the specified key.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -145,7 +146,7 @@ Obtains the value of the specified key in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -183,7 +184,7 @@ Obtains the index of the first occurrence of an element with the specified key i
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -221,7 +222,7 @@ Obtains the index of the first occurrence of an element with the specified value
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -259,7 +260,7 @@ Obtains the key of the element at the specified position in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -284,24 +285,24 @@ Obtains the value of an element at the specified position in this container.
**Parameters**
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| index | number | Yes| Position index of the target element.|
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| index | number | Yes| Position index of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
| T | Returns the value of the element if obtained; returns **undefined** otherwise.|
| Type| Description|
| -------- | -------- |
| T | Returns the value of the element if obtained; returns **undefined** otherwise.|
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The getValueAt method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of index is out of range. |
**Example**
...
...
@@ -328,7 +329,7 @@ Clones this container and returns a copy. The modification to the copy does not
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -361,7 +362,7 @@ Adds an element to this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -397,7 +398,7 @@ Removes an element with the specified key from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -435,7 +436,7 @@ Removes an element at the specified position from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -474,12 +475,12 @@ Removes elements in a specified range from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeRangeFrom method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of index is out of range. |
**Example**
...
...
@@ -508,12 +509,12 @@ Sets a value for an element at the specified position in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200011 | The setValueAt method cannot be bound. |
| 10200001 | The parameter value is out of range. |
| 10200001 | The value of index is out of range. |
**Example**
...
...
@@ -541,7 +542,7 @@ Obtains a string that contains all elements in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -567,7 +568,7 @@ Clears this container and sets its length to **0**.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -607,7 +608,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -641,7 +642,7 @@ Obtains an iterator object that contains key-value pairs, where the key is of th
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
> 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.
**Queue** follows the principle of First In First Out (FIFO). It supports insertion of elements at the end and removal from the front of the queue. **Queue** is implemented based on the queue data structure.
...
...
@@ -41,7 +40,7 @@ A constructor used to create a **Queue** instance.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -76,7 +75,7 @@ Adds an element at the end of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -110,7 +109,7 @@ Removes the first element from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -144,7 +143,7 @@ Obtains the first element of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -187,7 +186,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -222,7 +221,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
> 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.
**Stack** is implemented based on the array data structure. It follows the principle Last Out First In (LOFI) and supports data insertion and removal at one end.
...
...
@@ -40,7 +39,7 @@ A constructor used to create a **Stack** instance.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -75,7 +74,7 @@ Adds an element at the top of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -109,7 +108,7 @@ Removes the top element from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -143,7 +142,7 @@ Obtains the top element of this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -182,7 +181,7 @@ Obtains the index of the first occurrence of the specified element in this conta
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -225,7 +224,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -260,7 +259,7 @@ Checks whether this container is empty (contains no elements).
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -293,7 +292,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
> 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.
**TreeMap** stores key-value (KV) pairs. Each key must be unique and have only one value.
...
...
@@ -49,7 +48,7 @@ A constructor used to create a **TreeMap** instance.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -78,7 +77,7 @@ Checks whether this container is empty (contains no element).
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -114,7 +113,7 @@ Checks whether this container has the specified key.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -152,7 +151,7 @@ Checks whether this container has the specified value.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -190,7 +189,7 @@ Obtains the value of the specified key in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -222,7 +221,7 @@ Obtains the first key in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -254,7 +253,7 @@ Obtains the last key in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -282,11 +281,11 @@ Adds all elements in a **TreeMap** instance to this container.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| map | TreeMap<K,V> | Yes| **TreeMap**instance whose elements are to be added to the current container.|
| map | TreeMap<K,V> | Yes| **TreeMap**object to be added to the container.|
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -299,7 +298,11 @@ let treeMap = new TreeMap();
treeMap.set("squirrel",123);
treeMap.set("sparrow",356);
letmap=newTreeMap();
treeMap.setAll(map);
map.set("demo",12);
map.setAll(treeMap);// Add all elements in the treeMap to the map.
map.forEach((value,key)=>{
console.log("test"+value,key);// Print result: 12 demo, 356 sparrow, and 123 squirrel
})
```
...
...
@@ -326,7 +329,7 @@ Adds an element to this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -362,7 +365,7 @@ Removes the element with the specified key from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -400,7 +403,7 @@ Obtains the key that is placed in front of the input key in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -439,7 +442,7 @@ Obtains the key that is placed next to the input key in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -478,7 +481,7 @@ Replaces an element in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -503,7 +506,7 @@ Clears this container and sets its length to **0**.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -535,7 +538,7 @@ Obtains an iterator that contains all the keys in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -572,7 +575,7 @@ Obtains an iterator that contains all the values in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -617,7 +620,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -651,7 +654,7 @@ Obtains an iterator that contains all the elements in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -688,7 +691,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
> 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.
**TreeSet** is implemented based on **[TreeMap](js-apis-treemap.md)**. In **TreeSet**, only **value** objects are processed. **TreeSet** can be used to store values, each of which must be unique.
...
...
@@ -46,7 +45,7 @@ A constructor used to create a **TreeSet** instance.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -75,7 +74,7 @@ Checks whether this container is empty (contains no element).
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -111,7 +110,7 @@ Checks whether this container has the specified value.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -143,7 +142,7 @@ Obtains the value of the first element in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -175,7 +174,7 @@ Obtains the value of the last element in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -213,7 +212,7 @@ Adds an element to this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -249,7 +248,7 @@ Removes the element with the specified key from this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -287,7 +286,7 @@ Obtains the value that is placed in front of the input key in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -326,7 +325,7 @@ Obtains the value that is placed next to the input key in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -359,7 +358,7 @@ Removes the first element in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -391,7 +390,7 @@ Removes the last element in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -417,7 +416,7 @@ Clears this container and sets its length to **0**.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -449,7 +448,7 @@ Obtains an iterator that contains all the values in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -494,7 +493,7 @@ callbackfn
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -528,7 +527,7 @@ Obtains an iterator that contains all the elements in this container.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
...
...
@@ -566,7 +565,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Error codes**
For details about the error codes, see [containers Error Codes](../errorcodes/errorcode-containers.md).
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| protocol | string | Yes| Yes| Protocol in a URL.|
| search | string | Yes| Yes| Serialized query string in a URL.|
| searchParams | URLSearchParams | Yes| No| **URLSearchParams** object allowing access to the query parameters in a URL.|
| URLParams | URLParams | Yes| No| **URLParams** object allowing access to the query parameters in a URL.|
| searchParams<sup>(deprecated)</sup> | [URLSearchParams](#urlsearchparamsdeprecated) | Yes| No| **URLSearchParams** object allowing access to the query parameters in a URL.<br>- **NOTE**: This attribute is supported since API version 7 and is deprecated since API version 9. You are advised to use params<sup>9+</sup> instead.|
| params<sup>9+</sup> | [URLParams](#urlparams9) | Yes| No| **URLParams** object allowing access to the query parameters in a URL.|
| username | string | Yes| Yes| Username in a URL.|
### constructor<sup>(deprecated)</sup>
constructor(url: string, base?: string | URL)
Creates a URL.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [parseURL<sup>9+</sup>](#parseurl9) instead.
| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-inner-app-context.md) or [Stage Model](js-apis-application-context.md).|
| inFile | string | Yes | Path of the folder or file to zip. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).|
| outFile | string | Yes | Path of the zipped file. The file name extension is .zip. |
| options | [Options](#options) | Yes | Optional parameters for the zip operation. |
...
...
@@ -39,6 +39,7 @@ Zips a file. This API uses a promise to return the result.
```typescript
// Zip a file.
// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through the context.
// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through the context.
importzlibfrom'@ohos.zlib';
letinFile='/xxx/xxx';
letoutFile='/xxx/xxx.zip';
...
...
@@ -89,7 +91,7 @@ Unzips a file. This API uses a promise to return the result.
| inFile | string | Yes | Path of the folder or file to unzip. For details about the path, see [FA Model](js-apis-inner-app-context.md) or [Stage Model](js-apis-application-context.md).|
| inFile | string | Yes | Path of the file to unzip. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).|
| outFile | string | Yes | Path of the unzipped file. |
| options | [Options](#options) | Yes | Optional parameters for the unzip operation. |
...
...
@@ -103,6 +105,7 @@ Unzips a file. This API uses a promise to return the result.
```typescript
// Unzip a file.
// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through the context.
importzlibfrom'@ohos.zlib';
letinFile='/xx/xxx.zip';
letoutFile='/xxx';
...
...
@@ -131,7 +134,7 @@ Compresses a file. This API uses an asynchronous callback to return the result.
| inFile | string | Yes | Path of the folder or file to compress. For details about the path, see [FA Model](js-apis-inner-app-context.md) or [Stage Model](js-apis-application-context.md).|
| inFile | string | Yes | Path of the folder or file to compress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).|
| outFile | string | Yes | Path of the compressed file. |
| AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. |
...
...
@@ -141,14 +144,14 @@ Compresses a file. This API uses an asynchronous callback to return the result.
For details about the error codes, see [zlib Error Codes](../errorcodes/errorcode-zlib.md).
| 900002 | The Input destination file is invalid. |
| 900001 | The input source file is invalid. |
| 900002 | The input destination file is invalid. |
**Example**
```typescript
// Compress a file.
// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context.
// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through the context.
importzlibfrom'@ohos.zlib';
letinFile='/xxx/filename.xxx';
letoutFile='/xxx/xxx.zip';
...
...
@@ -179,7 +182,7 @@ Compresses a file. This API uses a promise to return the result.
| inFile | string | Yes | Path of the folder or file to compress. For details about the path, see [FA Model](js-apis-inner-app-context.md) or [Stage Model](js-apis-application-context.md).|
| inFile | string | Yes | Path of the folder or file to compress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).|
| outFile | string | Yes | Path of the compressed file. |
| 900002 | The Input destination file is invalid. |
| 900001 | The input source file is invalid. |
| 900002 | The input destination file is invalid. |
```typescript
// Compress a file.
// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context.
// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through the context.
importzlibfrom'@ohos.zlib';
letinFile='/xxx/filename.xxx';
letoutFile='/xxx/xxx.zip';
...
...
@@ -229,7 +232,7 @@ Decompresses a file. This API uses an asynchronous callback to return the result
| inFile | string | Yes | Path of the file to decompress. For details about the path, see [FA Model](js-apis-inner-app-context.md) or [Stage Model](js-apis-application-context.md).|
| inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).|
| outFile | string | Yes | Path of the decompressed file. |
| AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. |
...
...
@@ -240,14 +243,14 @@ For details about the error codes, see [zlib Error Codes](../errorcodes/errorcod
| 900002 | The Input destination file is invalid. |
| 900001 | The input source file is invalid. |
| 900002 | The input destination file is invalid. |
**Example**
```typescript
// Decompress a file.
// The path used in the code must be the application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context.
// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through the context.
| inFile | string | Yes | Path of the file to decompress. For details about the path, see [FA Model](js-apis-inner-app-context.md) or [Stage Model](js-apis-application-context.md).|
| inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).|
| outFile | string | Yes | Path of the decompressed file. |
| 900002 | The Input destination file is invalid. |
| 900001 | The input source file is invalid. |
| 900002 | The input destination file is invalid. |
```typescript
// Decompress a file.
// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context.
// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through the context.