> 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.
## Modules to Import
```
```ts
importArrayListfrom'@ohos.util.ArrayList'
```
...
...
@@ -30,7 +30,7 @@ A constructor used to create an **ArrayList** instance.
**Example**
```
```ts
letarrayList=newArrayList();
```
...
...
@@ -55,7 +55,7 @@ Adds an entry at the end of this container.
**Example**
```
```ts
letarrayList=newArrayList();
letresult=arrayList.add("a");
letresult1=arrayList.add(1);
...
...
@@ -80,7 +80,7 @@ Inserts an entry at the specified position in this container.
**Example**
```
```ts
letarrayList=newArrayList();
arrayList.insert("A",0);
arrayList.insert(0,1);
...
...
@@ -107,7 +107,7 @@ Checks whether this container has the specified entry.
> 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.
## Modules to Import
```
```ts
importDequefrom'@ohos.util.Deque'
```
...
...
@@ -30,7 +30,7 @@ A constructor used to create a **Deque** instance.
**Example**
```
```ts
letdeque=newDeque();
```
...
...
@@ -48,7 +48,7 @@ Inserts an entry at the front of this container.
**Example**
```
```ts
letdeque=newDeque();
deque.insertFront("a");
deque.insertFront(1);
...
...
@@ -72,7 +72,7 @@ Inserts an entry at the end of this container.
**Example**
```
```ts
letdeque=newDeque();
deque.insertEnd("a");
deque.insertEnd(1);
...
...
@@ -102,7 +102,7 @@ Checks whether this container has the specified entry.
**Example**
```
```ts
letdeque=newDeque();
letresult=deque.has("Ahfbrgrbgnutfodgorrogorg");
deque.insertFront("Ahfbrgrbgnutfodgorrogorg");
...
...
@@ -123,7 +123,7 @@ Removes the first entry of this container.
**Example**
```
```ts
letdeque=newDeque();
deque.insertFront(2);
deque.insertFront(4);
...
...
@@ -147,7 +147,7 @@ Removes the last entry of this container.
**Example**
```
```ts
letdeque=newDeque();
deque.insertFront(2);
deque.insertEnd(4);
...
...
@@ -181,7 +181,7 @@ callbackfn
**Example**
```
```ts
letdeque=newDeque();
deque.insertFront(2);
deque.insertEnd(4);
...
...
@@ -206,7 +206,7 @@ Obtains the first entry of this container.
**Example**
```
```ts
letdeque=newDeque();
deque.insertEnd(2);
deque.insertEnd(4);
...
...
@@ -229,7 +229,7 @@ Obtains the last entry of this container.
**Example**
```
```ts
letdeque=newDeque();
deque.insertFront(2);
deque.insertFront(4);
...
...
@@ -252,7 +252,7 @@ Obtains an iterator, each item of which is a JavaScript object.
> 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.
## Modules to Import
```
```ts
importHashMapfrom'@ohos.util.HashMap'
```
...
...
@@ -32,7 +32,7 @@ A constructor used to create a **HashMap** instance.
**Example**
```
```ts
lethashMap=newHashMap();
```
...
...
@@ -51,7 +51,7 @@ Checks whether this container is empty (contains no entry).
**Example**
```
```ts
consthashMap=newHashMap();
letresult=hashMap.isEmpty();
```
...
...
@@ -77,7 +77,7 @@ Checks whether this container contains the specified key.
> 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.
## Modules to Import
```
```ts
importHashSetfrom'@ohos.util.HashSet';
```
...
...
@@ -32,7 +32,7 @@ A constructor used to create a **HashSet** instance.
**Example**
```
```ts
lethashSet=newHashSet();
```
...
...
@@ -51,9 +51,9 @@ Checks whether this container is empty (contains no entry).
**Example**
```
```ts
consthashSet=newHashSet();
hashSet.isEmpty();
letresult=hashSet.isEmpty();
```
...
...
@@ -77,7 +77,7 @@ Checks whether this container contains the specified entry.
> 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.
> 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.
## Modules to Import
```
```ts
importLinkedListfrom'@ohos.util.LinkedList'
```
...
...
@@ -34,7 +34,7 @@ A constructor used to create a **LinkedList** instance.
**Example**
```
```ts
letlinkedList=newLinkedList();
```
...
...
@@ -59,7 +59,7 @@ Adds an entry at the end of this container.
**Example**
```
```ts
letlinkedList=newLinkedList();
letresult=linkedList.add("a");
letresult1=linkedList.add(1);
...
...
@@ -83,7 +83,7 @@ Adds an entry at the top of this container.
**Example**
```
```ts
letlinkedList=newLinkedList();
linkedList.addFirst("a");
linkedList.addFirst(1);
...
...
@@ -108,7 +108,7 @@ Inserts an entry at the specified position in this container.
**Example**
```
```ts
letlinkedList=newLinkedList();
linkedList.insert(0,"A");
linkedList.insert(1,0);
...
...
@@ -135,7 +135,7 @@ Checks whether this container has the specified entry.
> 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.
## Modules to Import
```
```ts
importListfrom'@ohos.util.List'
```
...
...
@@ -34,7 +34,7 @@ A constructor used to create a **List** instance.
**Example**
```
```ts
letlist=newList();
```
...
...
@@ -59,7 +59,7 @@ Adds an entry at the end of this container.
**Example**
```
```ts
letlist=newList();
letresult=list.add("a");
letresult1=list.add(1);
...
...
@@ -84,7 +84,7 @@ Inserts an entry at the specified position in this container.
**Example**
```
```ts
letlist=newList();
list.insert("A",0);
list.insert(0,1);
...
...
@@ -111,7 +111,7 @@ Checks whether this container has the specified entry.
**Example**
```
```ts
letlist=newList();
letresult=list.has("Ahfbrgrbgnutfodgorrogorg");
list.add("Ahfbrgrbgnutfodgorrogorg");
...
...
@@ -138,7 +138,7 @@ Obtains the entry at the specified position in this container.
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -170,7 +170,7 @@ Obtains the index of the last occurrence of the specified entry in this containe
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -202,7 +202,7 @@ Obtains the index of the first occurrence of the specified entry in this contain
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -235,7 +235,7 @@ Compares whether a specified object is equal to this container.
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -270,7 +270,7 @@ Removes an entry at the specified position from this container.
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -300,7 +300,7 @@ Removes the first occurrence of the specified entry from this container.
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -333,7 +333,7 @@ callbackfn
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -371,7 +371,7 @@ callbackfn
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -391,20 +391,20 @@ Sorts entries in this container.
**Parameters**
| Name| Value Type | Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| comparator | function | Yes| Callback invoked for sorting.|
| comparator | function | Yes | Callback invoked for sorting. |
comparator
| Name| Value Type | Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| firstValue | T | Yes| Previous entry.|
| secondValue | T | Yes| Next entry.|
| firstValue | T | Yes | Previous entry. |
| secondValue | T | Yes | Next entry. |
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -435,7 +435,7 @@ Obtains entries within a range in this container, including the entry at the sta
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -454,7 +454,7 @@ Clears this container and sets its length to **0**.
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -484,7 +484,7 @@ Replaces an entry at the specified position in this container with a given entry
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -502,13 +502,13 @@ Converts this container into an array.
**Return value**
| Value Type | Description|
| Type | Description |
| -------- | -------- |
| Array<T> | Array obtained.|
| Array<T> | Array obtained.|
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -531,7 +531,7 @@ Checks whether this container is empty (contains no entry).
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -554,7 +554,7 @@ Obtains the first entry in this container.
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -577,7 +577,7 @@ Obtains the last entry in this container.
**Example**
```
```ts
letlist=newList();
list.add(2);
list.add(4);
...
...
@@ -601,7 +601,7 @@ Obtains an iterator, each item of which is a JavaScript object.
> 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.
## Modules to Import
```
```ts
importPlainArrayfrom'@ohos.util.PlainArray'
```
...
...
@@ -32,7 +32,7 @@ A constructor used to create a **PlainArray** instance.
**Example**
```
```ts
letplainArray=newPlainArray();
```
...
...
@@ -51,7 +51,7 @@ Checks whether this container is empty.
**Example**
```
```ts
constplainArray=newPlainArray();
letresult=plainArray.isEmpty();
```
...
...
@@ -77,7 +77,7 @@ Checks whether this container contains the specified key.
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.has(1);
plainArray.add(1,"sddfhf");
...
...
@@ -105,7 +105,7 @@ Obtains the value of the specified key in this container.
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -133,7 +133,7 @@ Obtains the index of the first occurrence of an entry with the specified key in
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -161,7 +161,7 @@ Obtains the index of the first occurrence of an entry with the specified value i
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -189,7 +189,7 @@ Obtains the key of the entry at the specified position in this container.
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -216,7 +216,7 @@ Obtains the value of an entry at the specified position in this container.
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -237,7 +237,7 @@ Clones this container and returns a copy. The modification to the copy does not
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -260,7 +260,7 @@ Adds an entry to this container.
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
```
...
...
@@ -286,7 +286,7 @@ Removes an entry with the specified key from this container.
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -315,7 +315,7 @@ Removes an entry at the specified position from this container.
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -345,7 +345,7 @@ Removes entries in a specified range from this container.
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -368,7 +368,7 @@ Sets a value for an entry at the specified position in this container.
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -390,7 +390,7 @@ Obtains a string that contains all entries in this container.
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -406,7 +406,7 @@ Clears this container and sets its length to **0**.
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -436,7 +436,7 @@ callbackfn
**Example**
```
```ts
letplainArray=newPlainArray();
plainArray.add(1,"sddfhf");
plainArray.add(2,"sffdfhf");
...
...
@@ -460,7 +460,7 @@ Obtains an iterator, each item of which is a JavaScript object.
> 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.
## Modules to Import
```
```ts
importQueuefrom'@ohos.util.Queue'
```
...
...
@@ -33,7 +33,7 @@ A constructor used to create a **Queue** instance.
**Example**
```
```ts
letqueue=newQueue();
```
...
...
@@ -58,7 +58,7 @@ Adds an entry at the end of this container.
**Example**
```
```ts
letqueue=newQueue();
letresult=queue.add("a");
letresult1=queue.add(1);
...
...
@@ -83,7 +83,7 @@ Removes the first entry from this container.
**Example**
```
```ts
letqueue=newQueue();
queue.add(2);
queue.add(4);
...
...
@@ -107,7 +107,7 @@ Obtains the first entry of this container.
**Example**
```
```ts
letqueue=newQueue();
queue.add(2);
queue.add(4);
...
...
@@ -140,7 +140,7 @@ callbackfn
**Example**
```
```ts
letqueue=newQueue();
queue.add(2);
queue.add(4);
...
...
@@ -161,12 +161,12 @@ Obtains an iterator, each item of which is a JavaScript object.
> 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.
## Modules to Import
```
```ts
importStackfrom'@ohos.util.Stack'
```
...
...
@@ -33,7 +33,7 @@ A constructor used to create a **Stack** instance.
**Example**
```
```ts
letstack=newStack();
```
...
...
@@ -58,7 +58,7 @@ Adds an entry at the top of this container.
**Example**
```
```ts
letstack=newStack();
letresult=stack.push("a");
letresult1=stack.push(1);
...
...
@@ -82,7 +82,7 @@ Removes the top entry from this container.
**Example**
```
```ts
letstack=newStack();
stack.push(2);
stack.push(4);
...
...
@@ -106,7 +106,7 @@ Obtains the top entry of this container.
**Example**
```
```ts
letstack=newStack();
stack.push(2);
stack.push(4);
...
...
@@ -135,7 +135,7 @@ Obtains the index of the first occurrence of the specified entry in this contain
**Example**
```
```ts
letstack=newStack();
stack.push(2);
stack.push(4);
...
...
@@ -168,7 +168,7 @@ callbackfn
**Example**
```
```ts
letstack=newStack();
stack.push(2);
stack.push(4);
...
...
@@ -193,7 +193,7 @@ Checks whether this container is empty (contains no entries).
**Example**
```
```ts
letstack=newStack();
stack.push(2);
stack.push(4);
...
...
@@ -216,7 +216,7 @@ Obtains an iterator, each item of which is a JavaScript object.
> 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.
## Modules to Import
```
```ts
importTreeMapfrom'@ohos.util.TreeMap'
```
...
...
@@ -38,7 +38,7 @@ A constructor used to create a **TreeMap** instance.
**Example**
```
```ts
lettreeMap=newTreeMap();
```
...
...
@@ -57,7 +57,7 @@ Checks whether this container is empty (contains no entry).
**Example**
```
```ts
consttreeMap=newTreeMap();
letresult=treeMap.isEmpty();
```
...
...
@@ -83,7 +83,7 @@ Checks whether this container has the specified key.
> 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.
## Modules to Import
```
```ts
importTreeSetfrom'@ohos.util.TreeSet'
```
...
...
@@ -38,7 +38,7 @@ A constructor used to create a **TreeSet** instance.
**Example**
```
```ts
lettreeSet=newTreeSet();
```
...
...
@@ -57,7 +57,7 @@ Checks whether this container is empty (contains no entry).
**Example**
```
```ts
consttreeSet=newTreeSet();
letresult=treeSet.isEmpty();
```
...
...
@@ -83,7 +83,7 @@ Checks whether this container has the specified value.
**Example**
```
```ts
lettreeSet=newTreeSet();
treeSet.has(123);
treeSet.add(123);
...
...
@@ -105,7 +105,7 @@ Obtains the value of the first entry in this container.
**Example**
```
```ts
lettreeSet=newTreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
...
...
@@ -127,7 +127,7 @@ Obtains the value of the last entry in this container.
**Example**
```
```ts
lettreeSet=newTreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs");
...
...
@@ -155,7 +155,7 @@ Adds an entry to this container.
> 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.
## Modules to Import
```
```ts
importVectorfrom'@ohos.util.Vector'
```
...
...
@@ -33,7 +33,7 @@ A constructor used to create a **Vector** instance.
**Example**
```
```ts
letvector=newVector();
```
...
...
@@ -58,7 +58,7 @@ Adds an entry at the end of this container.
**Example**
```
```ts
letvector=newVector();
letresult=vector.add("a");
letresult1=vector.add(1);
...
...
@@ -83,7 +83,7 @@ Inserts an entry at the specified position in this container.
**Example**
```
```ts
letvector=newVector();
vector.insert("A",0);
vector.insert(0,1);
...
...
@@ -110,7 +110,7 @@ Checks whether this container has the specified entry.