未验证 提交 ac566133 编写于 作者: O openharmony_ci 提交者: Gitee

!4105 翻译完成:3901 Solve the problem of console Log error

Merge pull request !4105 from wusongqing/TR3901
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import ArrayList from '@ohos.util.ArrayList' import ArrayList from '@ohos.util.ArrayList';
``` ```
## System Capabilities ## System Capabilities
...@@ -30,7 +30,7 @@ A constructor used to create an **ArrayList** instance. ...@@ -30,7 +30,7 @@ A constructor used to create an **ArrayList** instance.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
``` ```
...@@ -55,7 +55,7 @@ Adds an entry at the end of this container. ...@@ -55,7 +55,7 @@ Adds an entry at the end of this container.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
let result = arrayList.add("a"); let result = arrayList.add("a");
let result1 = arrayList.add(1); let result1 = arrayList.add(1);
...@@ -80,7 +80,7 @@ Inserts an entry at the specified position in this container. ...@@ -80,7 +80,7 @@ Inserts an entry at the specified position in this container.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.insert("A", 0); arrayList.insert("A", 0);
arrayList.insert(0, 1); arrayList.insert(0, 1);
...@@ -107,7 +107,7 @@ Checks whether this container has the specified entry. ...@@ -107,7 +107,7 @@ Checks whether this container has the specified entry.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
let result = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); let result = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
arrayList.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); arrayList.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
...@@ -134,7 +134,7 @@ Obtains the index of the first occurrence of the specified entry in this contain ...@@ -134,7 +134,7 @@ Obtains the index of the first occurrence of the specified entry in this contain
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -166,7 +166,7 @@ Obtains the index of the last occurrence of the specified entry in this containe ...@@ -166,7 +166,7 @@ Obtains the index of the last occurrence of the specified entry in this containe
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -198,7 +198,7 @@ Removes an entry with the specified position from this container. ...@@ -198,7 +198,7 @@ Removes an entry with the specified position from this container.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -228,7 +228,7 @@ Removes the first occurrence of the specified entry from this container. ...@@ -228,7 +228,7 @@ Removes the first occurrence of the specified entry from this container.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -252,7 +252,7 @@ Removes from this container all of the entries within a range, including the ent ...@@ -252,7 +252,7 @@ Removes from this container all of the entries within a range, including the ent
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -287,7 +287,7 @@ callbackfn ...@@ -287,7 +287,7 @@ callbackfn
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -325,14 +325,14 @@ callbackfn ...@@ -325,14 +325,14 @@ callbackfn
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
arrayList.add(5); arrayList.add(5);
arrayList.add(4); arrayList.add(4);
arrayList.forEach((value, index) => { arrayList.forEach((value, index) => {
console.log(value, index); console.log("value:" + value, index);
}); });
``` ```
...@@ -357,14 +357,14 @@ comparator ...@@ -357,14 +357,14 @@ comparator
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
arrayList.add(5); arrayList.add(5);
arrayList.add(4); arrayList.add(4);
arrayList.sort(a, (b => a - b)); arrayList.sort((a, b) => a - b);
arrayList.sort(a, (b => b - a)); arrayList.sort((a, b) => b - a);
arrayList.sort(); arrayList.sort();
``` ```
...@@ -389,7 +389,7 @@ Obtains entries within a range in this container, including the entry at the sta ...@@ -389,7 +389,7 @@ Obtains entries within a range in this container, including the entry at the sta
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -408,7 +408,7 @@ Clears this container and sets its length to **0**. ...@@ -408,7 +408,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -432,7 +432,7 @@ Clones this container and returns a copy. The modification to the copy does not ...@@ -432,7 +432,7 @@ Clones this container and returns a copy. The modification to the copy does not
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -455,7 +455,7 @@ Obtains the capacity of this container. ...@@ -455,7 +455,7 @@ Obtains the capacity of this container.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -478,7 +478,7 @@ Converts this container into an array. ...@@ -478,7 +478,7 @@ Converts this container into an array.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -501,7 +501,7 @@ Checks whether this container is empty (contains no entry). ...@@ -501,7 +501,7 @@ Checks whether this container is empty (contains no entry).
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -524,7 +524,7 @@ Increases the capacity of this container. ...@@ -524,7 +524,7 @@ Increases the capacity of this container.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -542,7 +542,7 @@ Trims the capacity of this container to its current length. ...@@ -542,7 +542,7 @@ Trims the capacity of this container to its current length.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -565,7 +565,7 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -565,7 +565,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Example** **Example**
``` ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
arrayList.add(2); arrayList.add(2);
arrayList.add(4); arrayList.add(4);
...@@ -574,14 +574,14 @@ arrayList.add(4); ...@@ -574,14 +574,14 @@ arrayList.add(4);
// Method 1: // Method 1:
for (let item of arrayList) { for (let item of arrayList) {
console.log(item); console.log("value:" + item);
} }
// Method 2: // Method 2:
let iter = arrayList[Symbol.iterator](); let iter = arrayList[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import Deque from '@ohos.util.Deque' import Deque from '@ohos.util.Deque';
``` ```
## System Capabilities ## System Capabilities
...@@ -30,7 +30,7 @@ A constructor used to create a **Deque** instance. ...@@ -30,7 +30,7 @@ A constructor used to create a **Deque** instance.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
``` ```
...@@ -48,7 +48,7 @@ Inserts an entry at the front of this container. ...@@ -48,7 +48,7 @@ Inserts an entry at the front of this container.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertFront("a"); deque.insertFront("a");
deque.insertFront(1); deque.insertFront(1);
...@@ -72,7 +72,7 @@ Inserts an entry at the end of this container. ...@@ -72,7 +72,7 @@ Inserts an entry at the end of this container.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertEnd("a"); deque.insertEnd("a");
deque.insertEnd(1); deque.insertEnd(1);
...@@ -102,7 +102,7 @@ Checks whether this container has the specified entry. ...@@ -102,7 +102,7 @@ Checks whether this container has the specified entry.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
let result = deque.has("Ahfbrgrbgnutfodgorrogorg"); let result = deque.has("Ahfbrgrbgnutfodgorrogorg");
deque.insertFront("Ahfbrgrbgnutfodgorrogorg"); deque.insertFront("Ahfbrgrbgnutfodgorrogorg");
...@@ -123,7 +123,7 @@ Removes the first entry of this container. ...@@ -123,7 +123,7 @@ Removes the first entry of this container.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertFront(2); deque.insertFront(2);
deque.insertFront(4); deque.insertFront(4);
...@@ -147,7 +147,7 @@ Removes the last entry of this container. ...@@ -147,7 +147,7 @@ Removes the last entry of this container.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertFront(2); deque.insertFront(2);
deque.insertEnd(4); deque.insertEnd(4);
...@@ -181,14 +181,14 @@ callbackfn ...@@ -181,14 +181,14 @@ callbackfn
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertFront(2); deque.insertFront(2);
deque.insertEnd(4); deque.insertEnd(4);
deque.insertFront(5); deque.insertFront(5);
deque.insertEnd(4); deque.insertEnd(4);
deque.forEach((value, index) => { deque.forEach((value, index) => {
console.log(value, index); console.log("value:" + value, index);
}); });
``` ```
...@@ -206,7 +206,7 @@ Obtains the first entry of this container. ...@@ -206,7 +206,7 @@ Obtains the first entry of this container.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertEnd(2); deque.insertEnd(2);
deque.insertEnd(4); deque.insertEnd(4);
...@@ -229,7 +229,7 @@ Obtains the last entry of this container. ...@@ -229,7 +229,7 @@ Obtains the last entry of this container.
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertFront(2); deque.insertFront(2);
deque.insertFront(4); deque.insertFront(4);
...@@ -252,7 +252,7 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -252,7 +252,7 @@ Obtains an iterator, each item of which is a JavaScript object.
| IterableIterator<T> | Iterator obtained.| | IterableIterator<T> | Iterator obtained.|
**Example** **Example**
``` ```ts
let deque = new Deque(); let deque = new Deque();
deque.insertFront(2); deque.insertFront(2);
deque.insertFront(4); deque.insertFront(4);
...@@ -261,14 +261,14 @@ deque.insertFront(4); ...@@ -261,14 +261,14 @@ deque.insertFront(4);
// Method 1: // Method 1:
for (let item of deque) { for (let item of deque) {
console.log(item); console.log("value:" + item);
} }
// Method 2: // Method 2:
let iter = deque[Symbol.iterator](); let iter = deque[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import HashMap from '@ohos.util.HashMap' import HashMap from '@ohos.util.HashMap';
``` ```
## System Capabilities ## System Capabilities
...@@ -32,7 +32,7 @@ A constructor used to create a **HashMap** instance. ...@@ -32,7 +32,7 @@ A constructor used to create a **HashMap** instance.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
``` ```
...@@ -51,7 +51,7 @@ Checks whether this container is empty (contains no entry). ...@@ -51,7 +51,7 @@ Checks whether this container is empty (contains no entry).
**Example** **Example**
``` ```ts
const hashMap = new HashMap(); const hashMap = new HashMap();
let result = hashMap.isEmpty(); let result = hashMap.isEmpty();
``` ```
...@@ -77,7 +77,7 @@ Checks whether this container contains the specified key. ...@@ -77,7 +77,7 @@ Checks whether this container contains the specified key.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
let result = hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); let result = hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
...@@ -105,7 +105,7 @@ Checks whether this container contains the specified value. ...@@ -105,7 +105,7 @@ Checks whether this container contains the specified value.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
let result = hashMap.hasValue(123); let result = hashMap.hasValue(123);
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
...@@ -133,7 +133,7 @@ Obtains the value of the specified key in this container. ...@@ -133,7 +133,7 @@ Obtains the value of the specified key in this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
...@@ -155,7 +155,7 @@ Adds all entries in a **HashMap** instance to this container. ...@@ -155,7 +155,7 @@ Adds all entries in a **HashMap** instance to this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
...@@ -185,7 +185,7 @@ Adds an entry to this container. ...@@ -185,7 +185,7 @@ Adds an entry to this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
let result = hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); let result = hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
``` ```
...@@ -211,7 +211,7 @@ Removes an entry with the specified key from this container. ...@@ -211,7 +211,7 @@ Removes an entry with the specified key from this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
...@@ -227,7 +227,7 @@ Clears this container and sets its length to **0**. ...@@ -227,7 +227,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
...@@ -249,14 +249,14 @@ Obtains an iterator that contains all the entries in this container. ...@@ -249,14 +249,14 @@ Obtains an iterator that contains all the entries in this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
let iter = hashMap.keys(); let iter = hashMap.keys();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -276,14 +276,14 @@ Obtains an iterator that contains all the values in this container. ...@@ -276,14 +276,14 @@ Obtains an iterator that contains all the values in this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
let iter = hashMap.values(); let iter = hashMap.values();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -310,7 +310,7 @@ Replaces an entry in this container. ...@@ -310,7 +310,7 @@ Replaces an entry in this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("sdfs", 123); hashMap.set("sdfs", 123);
let result = hashMap.replace("sdfs", 357); let result = hashMap.replace("sdfs", 357);
...@@ -339,12 +339,12 @@ callbackfn ...@@ -339,12 +339,12 @@ callbackfn
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("sdfs", 123); hashMap.set("sdfs", 123);
hashMap.set("dfsghsf", 357); hashMap.set("dfsghsf", 357);
hashMap.forEach((value, key) => { hashMap.forEach((value, key) => {
console.log(value, key); console.log("value:" + value, key);
}); });
``` ```
...@@ -363,15 +363,15 @@ Obtains an iterator that contains all the entries in this container. ...@@ -363,15 +363,15 @@ Obtains an iterator that contains all the entries in this container.
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
let iter = hashMap.entries(); let iter = hashMap.entries();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp[0]); console.log("key:" + temp[0]);
console.log(temp[1]); console.log("value:" + temp[1]);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -390,23 +390,23 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -390,23 +390,23 @@ Obtains an iterator, each item of which is a JavaScript object.
| IterableIterator<[K, V]> | Iterator obtained.| | IterableIterator<[K, V]> | Iterator obtained.|
**Example** **Example**
``` ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
hashMap.set("sdfs", 356); hashMap.set("sdfs", 356);
// Method 1: // Method 1:
for (let item of hashMap) { for (let item of hashMap) {
console.log("key: " + item[0]); console.log("key:" + item[0]);
console.log("value: " + item[1]); console.log("value:" + item[1]);
} }
// Method 2: // Method 2:
let iter = hashMap[Symbol.iterator](); let iter = hashMap[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp[0]); console.log("key:" + temp[0]);
console.log(temp[1]); console.log("value:" + temp[1]);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## Modules to Import ## Modules to Import
``` ```ts
import HashSet from '@ohos.util.HashSet'; import HashSet from '@ohos.util.HashSet';
``` ```
...@@ -32,7 +32,7 @@ A constructor used to create a **HashSet** instance. ...@@ -32,7 +32,7 @@ A constructor used to create a **HashSet** instance.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
``` ```
...@@ -51,9 +51,9 @@ Checks whether this container is empty (contains no entry). ...@@ -51,9 +51,9 @@ Checks whether this container is empty (contains no entry).
**Example** **Example**
``` ```ts
const hashSet = new HashSet(); const hashSet = new HashSet();
hashSet.isEmpty(); let result = hashSet.isEmpty();
``` ```
...@@ -77,7 +77,7 @@ Checks whether this container contains the specified entry. ...@@ -77,7 +77,7 @@ Checks whether this container contains the specified entry.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
let result = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); let result = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
...@@ -105,7 +105,7 @@ Adds an entry to this container. ...@@ -105,7 +105,7 @@ Adds an entry to this container.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
let result = hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); let result = hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
``` ```
...@@ -131,7 +131,7 @@ Removes an entry from this container. ...@@ -131,7 +131,7 @@ Removes an entry from this container.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs"); hashSet.add("sdfs");
...@@ -147,7 +147,7 @@ Clears this container and sets its length to **0**. ...@@ -147,7 +147,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs"); hashSet.add("sdfs");
...@@ -169,14 +169,14 @@ Obtains an iterator that contains all the values in this container. ...@@ -169,14 +169,14 @@ Obtains an iterator that contains all the values in this container.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs"); hashSet.add("sdfs");
let iter = hashSet.values(); let iter = hashSet.values();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -204,12 +204,12 @@ callbackfn ...@@ -204,12 +204,12 @@ callbackfn
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
hashSet.add("sdfs"); hashSet.add("sdfs");
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.forEach((value, key) => { hashSet.forEach((value, key) => {
console.log(value, key); console.log("value:" + value, key);
}); });
``` ```
...@@ -227,15 +227,15 @@ Obtains an iterator that contains all the entries in this container. ...@@ -227,15 +227,15 @@ Obtains an iterator that contains all the entries in this container.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs"); hashSet.add("sdfs");
let iter = hashSet.entries(); let iter = hashSet.entries();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp[0]); console.log("key:" + temp[0]);
console.log(temp[1]); console.log("value:" + temp[1]);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -255,7 +255,7 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -255,7 +255,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Example** **Example**
``` ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.add("sdfs"); hashSet.add("sdfs");
...@@ -269,7 +269,7 @@ for (let item of hashSet) { ...@@ -269,7 +269,7 @@ for (let item of hashSet) {
let iter = hashSet[Symbol.iterator](); let iter = hashSet[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value: " + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import LightWeightMap from '@ohos.util.LightWeightMap' import LightWeightMap from '@ohos.util.LightWeightMap';
``` ```
## System Capabilities ## System Capabilities
...@@ -32,7 +32,7 @@ A constructor used to create a **LightWeightMap** instance. ...@@ -32,7 +32,7 @@ A constructor used to create a **LightWeightMap** instance.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
``` ```
...@@ -51,7 +51,7 @@ Checks whether this container is empty (contains no entry). ...@@ -51,7 +51,7 @@ Checks whether this container is empty (contains no entry).
**Example** **Example**
``` ```ts
const lightWeightMap = new LightWeightMap(); const lightWeightMap = new LightWeightMap();
let result = lightWeightMap.isEmpty(); let result = lightWeightMap.isEmpty();
``` ```
...@@ -77,7 +77,7 @@ Checks whether this container contains all entries of the specified **LightWeigh ...@@ -77,7 +77,7 @@ Checks whether this container contains all entries of the specified **LightWeigh
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
...@@ -107,7 +107,7 @@ Checks whether this container contains the specified key. ...@@ -107,7 +107,7 @@ Checks whether this container contains the specified key.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
let result = lightWeightMap.hasKey; let result = lightWeightMap.hasKey;
lightWeightMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
...@@ -136,7 +136,7 @@ Checks whether this container contains the specified value. ...@@ -136,7 +136,7 @@ Checks whether this container contains the specified value.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
let result = lightWeightMap.hasValue(123); let result = lightWeightMap.hasValue(123);
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
...@@ -158,7 +158,7 @@ Increases the capacity of this container. ...@@ -158,7 +158,7 @@ Increases the capacity of this container.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.increaseCapacityTo(10); lightWeightMap.increaseCapacityTo(10);
``` ```
...@@ -184,7 +184,7 @@ Obtains the value of the specified key in this container. ...@@ -184,7 +184,7 @@ Obtains the value of the specified key in this container.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
...@@ -212,7 +212,7 @@ Obtains the index of the first occurrence of an entry with the specified key in ...@@ -212,7 +212,7 @@ Obtains the index of the first occurrence of an entry with the specified key in
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
...@@ -240,7 +240,7 @@ Obtains the index of the first occurrence of an entry with the specified value i ...@@ -240,7 +240,7 @@ Obtains the index of the first occurrence of an entry with the specified value i
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
...@@ -268,7 +268,7 @@ Obtains the key of an entry at the specified position in this container. ...@@ -268,7 +268,7 @@ Obtains the key of an entry at the specified position in this container.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
...@@ -290,7 +290,7 @@ Adds all entries in a **LightWeightMap** instance to this container. ...@@ -290,7 +290,7 @@ Adds all entries in a **LightWeightMap** instance to this container.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
...@@ -319,7 +319,7 @@ Adds an entry to this container. ...@@ -319,7 +319,7 @@ Adds an entry to this container.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
let result = lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); let result = lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
``` ```
...@@ -345,7 +345,7 @@ Removes an entry with the specified key from this container. ...@@ -345,7 +345,7 @@ Removes an entry with the specified key from this container.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
...@@ -373,7 +373,7 @@ Removes an entry at the specified position from this container. ...@@ -373,7 +373,7 @@ Removes an entry at the specified position from this container.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
...@@ -402,7 +402,7 @@ Sets a value for an entry at the specified position in this container. ...@@ -402,7 +402,7 @@ Sets a value for an entry at the specified position in this container.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
...@@ -430,7 +430,7 @@ Obtains the value of an entry at the specified position in this container. ...@@ -430,7 +430,7 @@ Obtains the value of an entry at the specified position in this container.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
...@@ -446,7 +446,7 @@ Clears this container and sets its length to **0**. ...@@ -446,7 +446,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
...@@ -468,14 +468,14 @@ Obtains an iterator that contains all the keys in this container. ...@@ -468,14 +468,14 @@ Obtains an iterator that contains all the keys in this container.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
let iter = lightWeightMap.keys(); let iter = lightWeightMap.keys();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -495,14 +495,14 @@ Obtains an iterator that contains all the values in this container. ...@@ -495,14 +495,14 @@ Obtains an iterator that contains all the values in this container.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
let iter = lightWeightMap.values(); let iter = lightWeightMap.values();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -530,12 +530,12 @@ callbackfn ...@@ -530,12 +530,12 @@ callbackfn
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("sdfs", 123); lightWeightMap.set("sdfs", 123);
lightWeightMap.set("dfsghsf", 357); lightWeightMap.set("dfsghsf", 357);
lightWeightMap.forEach((value, key) => { lightWeightMap.forEach((value, key) => {
console.log(value, key); console.log("value:" + value, key);
}); });
``` ```
...@@ -554,15 +554,15 @@ Obtains an iterator that contains all the entries in this container. ...@@ -554,15 +554,15 @@ Obtains an iterator that contains all the entries in this container.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
let iter = lightWeightMap.entries(); let iter = lightWeightMap.entries();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp[0]); console.log("key:" + temp[0]);
console.log(temp[1]); console.log("value:" + temp[1]);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -581,7 +581,7 @@ Concatenates the entries in this container into a string and returns the string. ...@@ -581,7 +581,7 @@ Concatenates the entries in this container into a string and returns the string.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("A", 123); lightWeightMap.set("A", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
...@@ -602,23 +602,23 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -602,23 +602,23 @@ Obtains an iterator, each item of which is a JavaScript object.
**Example** **Example**
``` ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
lightWeightMap.set("sdfs", 356); lightWeightMap.set("sdfs", 356);
// Method 1: // Method 1:
for (let item of lightWeightMap) { for (let item of lightWeightMap) {
console.log("key: " + item[0]); console.log("key:" + item[0]);
console.log("value: " + item[1]); console.log("value:" + item[1]);
} }
// Method 2: // Method 2:
let iter = lightWeightMap[Symbol.iterator](); let iter = lightWeightMap[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp[0]); console.log("key:" + temp[0]);
console.log(temp[1]); console.log("value:" + temp[1]);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import LightWeightSet from '@ohos.util.LightWeightSet' import LightWeightSet from '@ohos.util.LightWeightSet';
``` ```
## System Capabilities ## System Capabilities
...@@ -32,7 +32,7 @@ A constructor used to create a **LightWeightSet** instance. ...@@ -32,7 +32,7 @@ A constructor used to create a **LightWeightSet** instance.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
``` ```
...@@ -51,7 +51,7 @@ Checks whether this container is empty. ...@@ -51,7 +51,7 @@ Checks whether this container is empty.
**Example** **Example**
``` ```ts
const lightWeightSet = new LightWeightSet(); const lightWeightSet = new LightWeightSet();
let result = lightWeightSet.isEmpty(); let result = lightWeightSet.isEmpty();
``` ```
...@@ -76,7 +76,7 @@ Adds an entry to this container. ...@@ -76,7 +76,7 @@ Adds an entry to this container.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
let result = lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); let result = lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
``` ```
...@@ -96,7 +96,7 @@ Adds all entries in a **LightWeightSet** instance to this container. ...@@ -96,7 +96,7 @@ Adds all entries in a **LightWeightSet** instance to this container.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
...@@ -126,7 +126,7 @@ Checks whether this container contains all entries of the specified **LightWeigh ...@@ -126,7 +126,7 @@ Checks whether this container contains all entries of the specified **LightWeigh
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
...@@ -156,7 +156,7 @@ Checks whether this container has the specified key. ...@@ -156,7 +156,7 @@ Checks whether this container has the specified key.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
let result = lightWeightSet.has(123); let result = lightWeightSet.has(123);
lightWeightSet.add(123); lightWeightSet.add(123);
...@@ -184,7 +184,7 @@ Checks whether this container contains objects of the same type as the specified ...@@ -184,7 +184,7 @@ Checks whether this container contains objects of the same type as the specified
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
...@@ -207,7 +207,7 @@ Increases the capacity of this container. ...@@ -207,7 +207,7 @@ Increases the capacity of this container.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.increaseCapacityTo(10); lightWeightSet.increaseCapacityTo(10);
``` ```
...@@ -233,7 +233,7 @@ Obtains the position index of the entry with the specified key in this container ...@@ -233,7 +233,7 @@ Obtains the position index of the entry with the specified key in this container
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
...@@ -261,7 +261,7 @@ Removes an entry of the specified key from this container. ...@@ -261,7 +261,7 @@ Removes an entry of the specified key from this container.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
...@@ -289,7 +289,7 @@ Removes the entry at the specified position from this container. ...@@ -289,7 +289,7 @@ Removes the entry at the specified position from this container.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
...@@ -317,7 +317,7 @@ Obtains the value of the entry at the specified position in this container. ...@@ -317,7 +317,7 @@ Obtains the value of the entry at the specified position in this container.
**Parameters** **Parameters**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
...@@ -333,7 +333,7 @@ Clears this container and sets its length to **0**. ...@@ -333,7 +333,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
...@@ -355,7 +355,7 @@ Obtains a string that contains all entries in this container. ...@@ -355,7 +355,7 @@ Obtains a string that contains all entries in this container.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
...@@ -377,7 +377,7 @@ Obtains an array that contains all objects in this container. ...@@ -377,7 +377,7 @@ Obtains an array that contains all objects in this container.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
...@@ -399,7 +399,7 @@ Obtains an iterator that contains all the values in this container. ...@@ -399,7 +399,7 @@ Obtains an iterator that contains all the values in this container.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
...@@ -434,12 +434,12 @@ callbackfn ...@@ -434,12 +434,12 @@ callbackfn
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
lightWeightSet.add("dfsghsf"); lightWeightSet.add("dfsghsf");
lightWeightSet.forEach((value, key) => { lightWeightSet.forEach((value, key) => {
console.log(value, key); console.log("value:" + value, key);
}); });
``` ```
...@@ -458,7 +458,7 @@ Obtains an iterator that contains all the entries in this container. ...@@ -458,7 +458,7 @@ Obtains an iterator that contains all the entries in this container.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
...@@ -485,21 +485,21 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -485,21 +485,21 @@ Obtains an iterator, each item of which is a JavaScript object.
**Example** **Example**
``` ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
lightWeightSet.add("sdfs"); lightWeightSet.add("sdfs");
// Method 1: // Method 1:
for (let item of lightWeightSet) { for (let item of lightWeightSet) {
console.log("value: " + item); console.log("value:" + item);
} }
// Method 2: // Method 2:
let iter = lightWeightSet[Symbol.iterator](); let iter = lightWeightSet[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import LinkedList from '@ohos.util.LinkedList' import LinkedList from '@ohos.util.LinkedList';
``` ```
## System Capability ## System Capability
...@@ -34,7 +34,7 @@ A constructor used to create a **LinkedList** instance. ...@@ -34,7 +34,7 @@ A constructor used to create a **LinkedList** instance.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
``` ```
...@@ -59,7 +59,7 @@ Adds an entry at the end of this container. ...@@ -59,7 +59,7 @@ Adds an entry at the end of this container.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
let result = linkedList.add("a"); let result = linkedList.add("a");
let result1 = linkedList.add(1); let result1 = linkedList.add(1);
...@@ -83,7 +83,7 @@ Adds an entry at the top of this container. ...@@ -83,7 +83,7 @@ Adds an entry at the top of this container.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.addFirst("a"); linkedList.addFirst("a");
linkedList.addFirst(1); linkedList.addFirst(1);
...@@ -108,7 +108,7 @@ Inserts an entry at the specified position in this container. ...@@ -108,7 +108,7 @@ Inserts an entry at the specified position in this container.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.insert(0, "A"); linkedList.insert(0, "A");
linkedList.insert(1, 0); linkedList.insert(1, 0);
...@@ -135,7 +135,7 @@ Checks whether this container has the specified entry. ...@@ -135,7 +135,7 @@ Checks whether this container has the specified entry.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
let result1 = linkedList.has("Ahfbrgrbgnutfodgorrogorg"); let result1 = linkedList.has("Ahfbrgrbgnutfodgorrogorg");
linkedList.add("Ahfbrgrbgnutfodgorrogorg"); linkedList.add("Ahfbrgrbgnutfodgorrogorg");
...@@ -162,7 +162,7 @@ Obtains an entry at the specified position in this container. ...@@ -162,7 +162,7 @@ Obtains an entry at the specified position in this container.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -194,7 +194,7 @@ Obtains the index of the last occurrence of the specified entry in this containe ...@@ -194,7 +194,7 @@ Obtains the index of the last occurrence of the specified entry in this containe
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -226,7 +226,7 @@ Obtains the index of the first occurrence of the specified entry in this contain ...@@ -226,7 +226,7 @@ Obtains the index of the first occurrence of the specified entry in this contain
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -258,7 +258,7 @@ Removes an entry at the specified position from this container. ...@@ -258,7 +258,7 @@ Removes an entry at the specified position from this container.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -282,7 +282,7 @@ Removes the first entry from this container. ...@@ -282,7 +282,7 @@ Removes the first entry from this container.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -306,7 +306,7 @@ Removes the last entry from this container. ...@@ -306,7 +306,7 @@ Removes the last entry from this container.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -336,7 +336,7 @@ Removes the first occurrence of the specified entry from this container. ...@@ -336,7 +336,7 @@ Removes the first occurrence of the specified entry from this container.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -365,7 +365,7 @@ Removes the first occurrence of the specified entry from this container. ...@@ -365,7 +365,7 @@ Removes the first occurrence of the specified entry from this container.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -394,7 +394,7 @@ Removes the last occurrence of the specified entry from this container. ...@@ -394,7 +394,7 @@ Removes the last occurrence of the specified entry from this container.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -417,7 +417,7 @@ Clones this container and returns a copy. The modification to the copy does not ...@@ -417,7 +417,7 @@ Clones this container and returns a copy. The modification to the copy does not
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -450,14 +450,14 @@ callbackfn ...@@ -450,14 +450,14 @@ callbackfn
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
linkedList.add(5); linkedList.add(5);
linkedList.add(4); linkedList.add(4);
linkedList.forEach((value, index) => { linkedList.forEach((value, index) => {
console.log(value, index); console.log("value:" + value, index);
}); });
``` ```
...@@ -469,7 +469,7 @@ Clears this container and sets its length to **0**. ...@@ -469,7 +469,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -499,7 +499,7 @@ Replaces an entry at the specified position in this container with a given entry ...@@ -499,7 +499,7 @@ Replaces an entry at the specified position in this container with a given entry
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -521,7 +521,7 @@ Converts this container into an array. ...@@ -521,7 +521,7 @@ Converts this container into an array.
| Array<T> | Array obtained.| | Array<T> | Array obtained.|
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -544,7 +544,7 @@ Obtains the first entry in this container. ...@@ -544,7 +544,7 @@ Obtains the first entry in this container.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -567,7 +567,7 @@ Obtains the last entry in this container. ...@@ -567,7 +567,7 @@ Obtains the last entry in this container.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -591,7 +591,7 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -591,7 +591,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Example** **Example**
``` ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
linkedList.add(2); linkedList.add(2);
linkedList.add(4); linkedList.add(4);
...@@ -600,14 +600,14 @@ linkedList.add(4); ...@@ -600,14 +600,14 @@ linkedList.add(4);
// Method 1: // Method 1:
for (let item of linkedList) { for (let item of linkedList) {
console.log(item); console.log("value:" + item);
} }
// Method 2: // Method 2:
let iter = linkedList[Symbol.iterator](); let iter = linkedList[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import List from '@ohos.util.List' import List from '@ohos.util.List';
``` ```
## System Capabilities ## System Capabilities
...@@ -34,7 +34,7 @@ A constructor used to create a **List** instance. ...@@ -34,7 +34,7 @@ A constructor used to create a **List** instance.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
``` ```
...@@ -59,7 +59,7 @@ Adds an entry at the end of this container. ...@@ -59,7 +59,7 @@ Adds an entry at the end of this container.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
let result = list.add("a"); let result = list.add("a");
let result1 = list.add(1); let result1 = list.add(1);
...@@ -84,7 +84,7 @@ Inserts an entry at the specified position in this container. ...@@ -84,7 +84,7 @@ Inserts an entry at the specified position in this container.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.insert("A", 0); list.insert("A", 0);
list.insert(0, 1); list.insert(0, 1);
...@@ -111,7 +111,7 @@ Checks whether this container has the specified entry. ...@@ -111,7 +111,7 @@ Checks whether this container has the specified entry.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
let result = list.has("Ahfbrgrbgnutfodgorrogorg"); let result = list.has("Ahfbrgrbgnutfodgorrogorg");
list.add("Ahfbrgrbgnutfodgorrogorg"); list.add("Ahfbrgrbgnutfodgorrogorg");
...@@ -138,7 +138,7 @@ Obtains the entry at the specified position in this container. ...@@ -138,7 +138,7 @@ Obtains the entry at the specified position in this container.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -170,7 +170,7 @@ Obtains the index of the last occurrence of the specified entry in this containe ...@@ -170,7 +170,7 @@ Obtains the index of the last occurrence of the specified entry in this containe
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -202,7 +202,7 @@ Obtains the index of the first occurrence of the specified entry in this contain ...@@ -202,7 +202,7 @@ Obtains the index of the first occurrence of the specified entry in this contain
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -235,7 +235,7 @@ Compares whether a specified object is equal to this container. ...@@ -235,7 +235,7 @@ Compares whether a specified object is equal to this container.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -270,7 +270,7 @@ Removes an entry at the specified position from this container. ...@@ -270,7 +270,7 @@ Removes an entry at the specified position from this container.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -300,7 +300,7 @@ Removes the first occurrence of the specified entry from this container. ...@@ -300,7 +300,7 @@ Removes the first occurrence of the specified entry from this container.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -333,7 +333,7 @@ callbackfn ...@@ -333,7 +333,7 @@ callbackfn
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -371,14 +371,14 @@ callbackfn ...@@ -371,14 +371,14 @@ callbackfn
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
list.add(5); list.add(5);
list.add(4); list.add(4);
list.forEach((value, index) => { list.forEach((value, index) => {
console.log(value, index); console.log("value: " + value, index);
}); });
``` ```
...@@ -404,14 +404,14 @@ comparator ...@@ -404,14 +404,14 @@ comparator
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
list.add(5); list.add(5);
list.add(4); list.add(4);
list.sort(a, (b => a - b)); list.sort((a, b) => a - b);
list.sort(a, (b => b - a)); list.sort((a, b) => b - a);
``` ```
### getSubList ### getSubList
...@@ -435,7 +435,7 @@ Obtains entries within a range in this container, including the entry at the sta ...@@ -435,7 +435,7 @@ Obtains entries within a range in this container, including the entry at the sta
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -454,7 +454,7 @@ Clears this container and sets its length to **0**. ...@@ -454,7 +454,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -484,7 +484,7 @@ Replaces an entry at the specified position in this container with a given entry ...@@ -484,7 +484,7 @@ Replaces an entry at the specified position in this container with a given entry
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -508,7 +508,7 @@ Converts this container into an array. ...@@ -508,7 +508,7 @@ Converts this container into an array.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -531,7 +531,7 @@ Checks whether this container is empty (contains no entry). ...@@ -531,7 +531,7 @@ Checks whether this container is empty (contains no entry).
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -554,7 +554,7 @@ Obtains the first entry in this container. ...@@ -554,7 +554,7 @@ Obtains the first entry in this container.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -577,7 +577,7 @@ Obtains the last entry in this container. ...@@ -577,7 +577,7 @@ Obtains the last entry in this container.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -601,7 +601,7 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -601,7 +601,7 @@ Obtains an iterator, each item of which is a JavaScript object.
**Example** **Example**
``` ```ts
let list = new List(); let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
...@@ -610,14 +610,14 @@ list.add(4); ...@@ -610,14 +610,14 @@ list.add(4);
// Method 1: // Method 1:
for (let item of list) { for (let item of list) {
console.log(item); console.log("value: " + item);
} }
// Method 2: // Method 2:
let iter = list[Symbol.iterator](); let iter = list[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value: " + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import PlainArray from '@ohos.util.PlainArray' import PlainArray from '@ohos.util.PlainArray';
``` ```
## System Capability ## System Capability
...@@ -32,7 +32,7 @@ A constructor used to create a **PlainArray** instance. ...@@ -32,7 +32,7 @@ A constructor used to create a **PlainArray** instance.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
``` ```
...@@ -51,7 +51,7 @@ Checks whether this container is empty. ...@@ -51,7 +51,7 @@ Checks whether this container is empty.
**Example** **Example**
``` ```ts
const plainArray = new PlainArray(); const plainArray = new PlainArray();
let result = plainArray.isEmpty(); let result = plainArray.isEmpty();
``` ```
...@@ -77,7 +77,7 @@ Checks whether this container contains the specified key. ...@@ -77,7 +77,7 @@ Checks whether this container contains the specified key.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.has(1); plainArray.has(1);
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
...@@ -105,7 +105,7 @@ Obtains the value of the specified key in this container. ...@@ -105,7 +105,7 @@ Obtains the value of the specified key in this container.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
...@@ -133,7 +133,7 @@ Obtains the index of the first occurrence of an entry with the specified key in ...@@ -133,7 +133,7 @@ Obtains the index of the first occurrence of an entry with the specified key in
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
...@@ -161,7 +161,7 @@ Obtains the index of the first occurrence of an entry with the specified value i ...@@ -161,7 +161,7 @@ Obtains the index of the first occurrence of an entry with the specified value i
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
...@@ -189,7 +189,7 @@ Obtains the key of the entry at the specified position in this container. ...@@ -189,7 +189,7 @@ Obtains the key of the entry at the specified position in this container.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
...@@ -216,7 +216,7 @@ Obtains the value of an entry at the specified position in this container. ...@@ -216,7 +216,7 @@ Obtains the value of an entry at the specified position in this container.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
...@@ -237,7 +237,7 @@ Clones this container and returns a copy. The modification to the copy does not ...@@ -237,7 +237,7 @@ Clones this container and returns a copy. The modification to the copy does not
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
...@@ -260,7 +260,7 @@ Adds an entry to this container. ...@@ -260,7 +260,7 @@ Adds an entry to this container.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
``` ```
...@@ -286,7 +286,7 @@ Removes an entry with the specified key from this container. ...@@ -286,7 +286,7 @@ Removes an entry with the specified key from this container.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
...@@ -315,7 +315,7 @@ Removes an entry at the specified position from this container. ...@@ -315,7 +315,7 @@ Removes an entry at the specified position from this container.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
...@@ -345,7 +345,7 @@ Removes entries in a specified range from this container. ...@@ -345,7 +345,7 @@ Removes entries in a specified range from this container.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
...@@ -368,7 +368,7 @@ Sets a value for an entry at the specified position in this container. ...@@ -368,7 +368,7 @@ Sets a value for an entry at the specified position in this container.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
...@@ -390,7 +390,7 @@ Obtains a string that contains all entries in this container. ...@@ -390,7 +390,7 @@ Obtains a string that contains all entries in this container.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
...@@ -406,7 +406,7 @@ Clears this container and sets its length to **0**. ...@@ -406,7 +406,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
...@@ -436,12 +436,12 @@ callbackfn ...@@ -436,12 +436,12 @@ callbackfn
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
plainArray.forEach((value, key) => { plainArray.forEach((value, index) => {
console.log(value, key); console.log("value:" + value, index);
}); });
``` ```
...@@ -460,23 +460,23 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -460,23 +460,23 @@ Obtains an iterator, each item of which is a JavaScript object.
**Example** **Example**
``` ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.add(1, "sddfhf"); plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf"); plainArray.add(2, "sffdfhf");
// Method 1: // Method 1:
for (let item of plainArray) { for (let item of plainArray) {
console.log("index: " + item[0]); console.log("index:" + item[0]);
console.log("value: " + item[1]); console.log("value:" + item[1]);
} }
// Method 2: // Method 2:
let iter = plainArray[Symbol.iterator](); let iter = plainArray[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp[0]); console.log("index:" + temp[0]);
console.log(temp[1]); console.log("value:" + temp[1]);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import Queue from '@ohos.util.Queue' import Queue from '@ohos.util.Queue';
``` ```
## System Capabilities ## System Capabilities
...@@ -33,7 +33,7 @@ A constructor used to create a **Queue** instance. ...@@ -33,7 +33,7 @@ A constructor used to create a **Queue** instance.
**Example** **Example**
``` ```ts
let queue = new Queue(); let queue = new Queue();
``` ```
...@@ -58,7 +58,7 @@ Adds an entry at the end of this container. ...@@ -58,7 +58,7 @@ Adds an entry at the end of this container.
**Example** **Example**
``` ```ts
let queue = new Queue(); let queue = new Queue();
let result = queue.add("a"); let result = queue.add("a");
let result1 = queue.add(1); let result1 = queue.add(1);
...@@ -83,7 +83,7 @@ Removes the first entry from this container. ...@@ -83,7 +83,7 @@ Removes the first entry from this container.
**Example** **Example**
``` ```ts
let queue = new Queue(); let queue = new Queue();
queue.add(2); queue.add(2);
queue.add(4); queue.add(4);
...@@ -107,7 +107,7 @@ Obtains the first entry of this container. ...@@ -107,7 +107,7 @@ Obtains the first entry of this container.
**Example** **Example**
``` ```ts
let queue = new Queue(); let queue = new Queue();
queue.add(2); queue.add(2);
queue.add(4); queue.add(4);
...@@ -140,14 +140,14 @@ callbackfn ...@@ -140,14 +140,14 @@ callbackfn
**Example** **Example**
``` ```ts
let queue = new Queue(); let queue = new Queue();
queue.add(2); queue.add(2);
queue.add(4); queue.add(4);
queue.add(5); queue.add(5);
queue.add(4); queue.add(4);
queue.forEach((value, index) => { queue.forEach((value, index) => {
console.log(value, index); console.log("value:" + value, index);
}); });
``` ```
...@@ -166,7 +166,7 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -166,7 +166,7 @@ Obtains an iterator, each item of which is a JavaScript object.
| IterableIterator<T> | Iterator obtained.| | IterableIterator<T> | Iterator obtained.|
**Example** **Example**
``` ```ts
let queue = new Queue(); let queue = new Queue();
queue.add(2); queue.add(2);
queue.add(4); queue.add(4);
...@@ -175,14 +175,14 @@ queue.add(4); ...@@ -175,14 +175,14 @@ queue.add(4);
// Method 1: // Method 1:
for (let item of queue) { for (let item of queue) {
console.log(item); console.log("value:" + item);
} }
// Method 2: // Method 2:
let iter = queue[Symbol.iterator](); let iter = queue[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import Stack from '@ohos.util.Stack' import Stack from '@ohos.util.Stack';
``` ```
## System Capabilities ## System Capabilities
...@@ -33,7 +33,7 @@ A constructor used to create a **Stack** instance. ...@@ -33,7 +33,7 @@ A constructor used to create a **Stack** instance.
**Example** **Example**
``` ```ts
let stack = new Stack(); let stack = new Stack();
``` ```
...@@ -58,7 +58,7 @@ Adds an entry at the top of this container. ...@@ -58,7 +58,7 @@ Adds an entry at the top of this container.
**Example** **Example**
``` ```ts
let stack = new Stack(); let stack = new Stack();
let result = stack.push("a"); let result = stack.push("a");
let result1 = stack.push(1); let result1 = stack.push(1);
...@@ -82,7 +82,7 @@ Removes the top entry from this container. ...@@ -82,7 +82,7 @@ Removes the top entry from this container.
**Example** **Example**
``` ```ts
let stack = new Stack(); let stack = new Stack();
stack.push(2); stack.push(2);
stack.push(4); stack.push(4);
...@@ -106,7 +106,7 @@ Obtains the top entry of this container. ...@@ -106,7 +106,7 @@ Obtains the top entry of this container.
**Example** **Example**
``` ```ts
let stack = new Stack(); let stack = new Stack();
stack.push(2); stack.push(2);
stack.push(4); stack.push(4);
...@@ -135,7 +135,7 @@ Obtains the index of the first occurrence of the specified entry in this contain ...@@ -135,7 +135,7 @@ Obtains the index of the first occurrence of the specified entry in this contain
**Example** **Example**
``` ```ts
let stack = new Stack(); let stack = new Stack();
stack.push(2); stack.push(2);
stack.push(4); stack.push(4);
...@@ -168,14 +168,14 @@ callbackfn ...@@ -168,14 +168,14 @@ callbackfn
**Example** **Example**
``` ```ts
let stack = new Stack(); let stack = new Stack();
stack.push(2); stack.push(2);
stack.push(4); stack.push(4);
stack.push(5); stack.push(5);
stack.push(4); stack.push(4);
stack.forEach((value, index) => { stack.forEach((value, index) => {
console.log(value, index); console.log("value:" + value, index);
}); });
``` ```
...@@ -193,7 +193,7 @@ Checks whether this container is empty (contains no entries). ...@@ -193,7 +193,7 @@ Checks whether this container is empty (contains no entries).
**Example** **Example**
``` ```ts
let stack = new Stack(); let stack = new Stack();
stack.push(2); stack.push(2);
stack.push(4); stack.push(4);
...@@ -216,7 +216,7 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -216,7 +216,7 @@ Obtains an iterator, each item of which is a JavaScript object.
| IterableIterator<T> | Iterator obtained.| | IterableIterator<T> | Iterator obtained.|
**Example** **Example**
``` ```ts
let stack = new Stack(); let stack = new Stack();
stack.push(2); stack.push(2);
stack.push(4); stack.push(4);
...@@ -225,14 +225,14 @@ stack.push(4); ...@@ -225,14 +225,14 @@ stack.push(4);
// Method 1: // Method 1:
for (let item of stack) { for (let item of stack) {
console.log(item); console.log("value:" + item);
} }
// Method 2: // Method 2:
let iter = stack[Symbol.iterator](); let iter = stack[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import TreeMap from '@ohos.util.TreeMap' import TreeMap from '@ohos.util.TreeMap';
``` ```
## System Capabilities ## System Capabilities
...@@ -38,7 +38,7 @@ A constructor used to create a **TreeMap** instance. ...@@ -38,7 +38,7 @@ A constructor used to create a **TreeMap** instance.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
``` ```
...@@ -57,7 +57,7 @@ Checks whether this container is empty (contains no entry). ...@@ -57,7 +57,7 @@ Checks whether this container is empty (contains no entry).
**Example** **Example**
``` ```ts
const treeMap = new TreeMap(); const treeMap = new TreeMap();
let result = treeMap.isEmpty(); let result = treeMap.isEmpty();
``` ```
...@@ -83,7 +83,7 @@ Checks whether this container has the specified key. ...@@ -83,7 +83,7 @@ Checks whether this container has the specified key.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
let result = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); let result = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
...@@ -111,7 +111,7 @@ Checks whether this container has the specified value. ...@@ -111,7 +111,7 @@ Checks whether this container has the specified value.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
let result = treeMap.hasValue(123); let result = treeMap.hasValue(123);
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
...@@ -139,7 +139,7 @@ Obtains the value of the specified key in this container. ...@@ -139,7 +139,7 @@ Obtains the value of the specified key in this container.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356); treeMap.set("sdfs", 356);
...@@ -161,7 +161,7 @@ Obtains the first key in this container. ...@@ -161,7 +161,7 @@ Obtains the first key in this container.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356); treeMap.set("sdfs", 356);
...@@ -183,7 +183,7 @@ Obtains the last key in this container. ...@@ -183,7 +183,7 @@ Obtains the last key in this container.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356); treeMap.set("sdfs", 356);
...@@ -205,7 +205,7 @@ Adds all entries in a **TreeMap** instance to this container. ...@@ -205,7 +205,7 @@ Adds all entries in a **TreeMap** instance to this container.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356); treeMap.set("sdfs", 356);
...@@ -235,7 +235,7 @@ Adds an entry to this container. ...@@ -235,7 +235,7 @@ Adds an entry to this container.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
``` ```
...@@ -261,7 +261,7 @@ Removes the entry with the specified key from this container. ...@@ -261,7 +261,7 @@ Removes the entry with the specified key from this container.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356); treeMap.set("sdfs", 356);
...@@ -289,7 +289,7 @@ Obtains the key that is placed in front of the input key in this container. ...@@ -289,7 +289,7 @@ Obtains the key that is placed in front of the input key in this container.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356); treeMap.set("sdfs", 356);
...@@ -318,7 +318,7 @@ Obtains the key that is placed next to the input key in this container. ...@@ -318,7 +318,7 @@ Obtains the key that is placed next to the input key in this container.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356); treeMap.set("sdfs", 356);
...@@ -347,7 +347,7 @@ Replaces an entry in this container. ...@@ -347,7 +347,7 @@ Replaces an entry in this container.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("sdfs", 123); treeMap.set("sdfs", 123);
let result = treeMap.replace("sdfs", 357); let result = treeMap.replace("sdfs", 357);
...@@ -362,7 +362,7 @@ Clears this container and sets its length to **0**. ...@@ -362,7 +362,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356); treeMap.set("sdfs", 356);
...@@ -384,14 +384,14 @@ Obtains an iterator that contains all the keys in this container. ...@@ -384,14 +384,14 @@ Obtains an iterator that contains all the keys in this container.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356); treeMap.set("sdfs", 356);
let iter = treeMap.keys(); let iter = treeMap.keys();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -411,14 +411,14 @@ Obtains an iterator that contains all the values in this container. ...@@ -411,14 +411,14 @@ Obtains an iterator that contains all the values in this container.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356); treeMap.set("sdfs", 356);
let iter = treeMap.values(); let iter = treeMap.values();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -446,12 +446,12 @@ callbackfn ...@@ -446,12 +446,12 @@ callbackfn
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("sdfs", 123); treeMap.set("sdfs", 123);
treeMap.set("dfsghsf", 357); treeMap.set("dfsghsf", 357);
treeMap.forEach((value, key) => { treeMap.forEach((value, key) => {
console.log(value, key); console.log("value:" + value, key);
}); });
``` ```
...@@ -470,15 +470,15 @@ Obtains an iterator that contains all the entries in this container. ...@@ -470,15 +470,15 @@ Obtains an iterator that contains all the entries in this container.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356); treeMap.set("sdfs", 356);
let iter = treeMap.entries(); let iter = treeMap.entries();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp[0]); console.log("key:" + temp[0]);
console.log(temp[1]); console.log("value:" + temp[1]);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -498,23 +498,23 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -498,23 +498,23 @@ Obtains an iterator, each item of which is a JavaScript object.
**Example** **Example**
``` ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
treeMap.set("sdfs", 356); treeMap.set("sdfs", 356);
// Method 1: // Method 1:
for (let item of treeMap) { for (let item of treeMap) {
console.log("key: " + item[0]); console.log("key:" + item[0]);
console.log("value: " + item[1]); console.log("value:" + item[1]);
} }
// Method 2: // Method 2:
let iter = treeMap[Symbol.iterator](); let iter = treeMap[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp[0]); console.log("key:" + temp[0]);
console.log(temp[1]); console.log("value:" + temp[1]);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import TreeSet from '@ohos.util.TreeSet' import TreeSet from '@ohos.util.TreeSet';
``` ```
## System Capabilities ## System Capabilities
...@@ -38,7 +38,7 @@ A constructor used to create a **TreeSet** instance. ...@@ -38,7 +38,7 @@ A constructor used to create a **TreeSet** instance.
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
``` ```
...@@ -57,7 +57,7 @@ Checks whether this container is empty (contains no entry). ...@@ -57,7 +57,7 @@ Checks whether this container is empty (contains no entry).
**Example** **Example**
``` ```ts
const treeSet = new TreeSet(); const treeSet = new TreeSet();
let result = treeSet.isEmpty(); let result = treeSet.isEmpty();
``` ```
...@@ -83,7 +83,7 @@ Checks whether this container has the specified value. ...@@ -83,7 +83,7 @@ Checks whether this container has the specified value.
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.has(123); treeSet.has(123);
treeSet.add(123); treeSet.add(123);
...@@ -105,7 +105,7 @@ Obtains the value of the first entry in this container. ...@@ -105,7 +105,7 @@ Obtains the value of the first entry in this container.
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs"); treeSet.add("sdfs");
...@@ -127,7 +127,7 @@ Obtains the value of the last entry in this container. ...@@ -127,7 +127,7 @@ Obtains the value of the last entry in this container.
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs"); treeSet.add("sdfs");
...@@ -155,7 +155,7 @@ Adds an entry to this container. ...@@ -155,7 +155,7 @@ Adds an entry to this container.
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
let result = treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); let result = treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
``` ```
...@@ -181,7 +181,7 @@ Removes the entry with the specified key from this container. ...@@ -181,7 +181,7 @@ Removes the entry with the specified key from this container.
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs"); treeSet.add("sdfs");
...@@ -209,7 +209,7 @@ Obtains the value that is placed in front of the input key in this container. ...@@ -209,7 +209,7 @@ Obtains the value that is placed in front of the input key in this container.
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs"); treeSet.add("sdfs");
...@@ -238,7 +238,7 @@ Obtains the value that is placed next to the input key in this container. ...@@ -238,7 +238,7 @@ Obtains the value that is placed next to the input key in this container.
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs"); treeSet.add("sdfs");
...@@ -261,7 +261,7 @@ Removes the first entry in this container. ...@@ -261,7 +261,7 @@ Removes the first entry in this container.
**Return value** **Return value**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs"); treeSet.add("sdfs");
...@@ -283,7 +283,7 @@ Removes the last entry in this container. ...@@ -283,7 +283,7 @@ Removes the last entry in this container.
**Return value** **Return value**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs"); treeSet.add("sdfs");
...@@ -299,7 +299,7 @@ Clears this container and sets its length to **0**. ...@@ -299,7 +299,7 @@ Clears this container and sets its length to **0**.
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs"); treeSet.add("sdfs");
...@@ -321,14 +321,14 @@ Obtains an iterator that contains all the values in this container. ...@@ -321,14 +321,14 @@ Obtains an iterator that contains all the values in this container.
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs"); treeSet.add("sdfs");
let iter = treeSet.values(); let iter = treeSet.values();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -356,12 +356,12 @@ callbackfn ...@@ -356,12 +356,12 @@ callbackfn
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.add("sdfs"); treeSet.add("sdfs");
treeSet.add("dfsghsf"); treeSet.add("dfsghsf");
treeSet.forEach((value, key) => { treeSet.forEach((value, key) => {
console.log(value, key) console.log("value:" + value, key)
}); });
``` ```
...@@ -380,15 +380,15 @@ Obtains an iterator that contains all the entries in this container. ...@@ -380,15 +380,15 @@ Obtains an iterator that contains all the entries in this container.
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs"); treeSet.add("sdfs");
let iter = treeSet.entries(); let iter = treeSet.entries();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp[0]); console.log("key:" + temp[0]);
console.log(temp[1]); console.log("value:" + temp[1]);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -409,21 +409,21 @@ Obtains an iterator, each item of which is a JavaScript object. ...@@ -409,21 +409,21 @@ Obtains an iterator, each item of which is a JavaScript object.
**Example** **Example**
``` ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
treeSet.add("sdfs"); treeSet.add("sdfs");
// Method 1: // Method 1:
for (let item of treeSet) { for (let item of treeSet) {
console.log("value: " + item); console.log("value:" + item);
} }
// Method 2: // Method 2:
let iter = treeSet[Symbol.iterator](); let iter = treeSet[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
## Modules to Import ## Modules to Import
``` ```ts
import Vector from '@ohos.util.Vector' import Vector from '@ohos.util.Vector';
``` ```
## System Capability ## System Capability
...@@ -33,7 +33,7 @@ A constructor used to create a **Vector** instance. ...@@ -33,7 +33,7 @@ A constructor used to create a **Vector** instance.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
``` ```
...@@ -58,7 +58,7 @@ Adds an entry at the end of this container. ...@@ -58,7 +58,7 @@ Adds an entry at the end of this container.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
let result = vector.add("a"); let result = vector.add("a");
let result1 = vector.add(1); let result1 = vector.add(1);
...@@ -83,7 +83,7 @@ Inserts an entry at the specified position in this container. ...@@ -83,7 +83,7 @@ Inserts an entry at the specified position in this container.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.insert("A", 0); vector.insert("A", 0);
vector.insert(0, 1); vector.insert(0, 1);
...@@ -110,7 +110,7 @@ Checks whether this container has the specified entry. ...@@ -110,7 +110,7 @@ Checks whether this container has the specified entry.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
let result = vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); let result = vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
vector.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); vector.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
...@@ -137,7 +137,7 @@ Obtains the index of the first occurrence of the specified entry in this contain ...@@ -137,7 +137,7 @@ Obtains the index of the first occurrence of the specified entry in this contain
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -169,7 +169,7 @@ Obtains the index of the last occurrence of the specified entry in this containe ...@@ -169,7 +169,7 @@ Obtains the index of the last occurrence of the specified entry in this containe
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -201,7 +201,7 @@ Removes an entry at the specified position from this container. ...@@ -201,7 +201,7 @@ Removes an entry at the specified position from this container.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -231,7 +231,7 @@ Removes the first occurrence of the specified entry from this container. ...@@ -231,7 +231,7 @@ Removes the first occurrence of the specified entry from this container.
**Return value** **Return value**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -255,7 +255,7 @@ Removes from this container all of the entries within a range, including the ent ...@@ -255,7 +255,7 @@ Removes from this container all of the entries within a range, including the ent
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -290,7 +290,7 @@ callbackfn ...@@ -290,7 +290,7 @@ callbackfn
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -328,14 +328,14 @@ callbackfn ...@@ -328,14 +328,14 @@ callbackfn
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
vector.add(5); vector.add(5);
vector.add(4); vector.add(4);
vector.forEach((value, index) => { vector.forEach((value, index) => {
console.log(value, index) console.log("value:" + value, index)
}); });
``` ```
...@@ -361,14 +361,14 @@ comparator ...@@ -361,14 +361,14 @@ comparator
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
vector.add(5); vector.add(5);
vector.add(4); vector.add(4);
vector.sort(a, (b => a - b)); vector.sort((a, b) => a - b);
vector.sort(a, (b => b - a)); vector.sort((a, b) => b - a);
vector.sort(); vector.sort();
``` ```
...@@ -393,7 +393,7 @@ Obtains entries within a range in this container, including the entry at the sta ...@@ -393,7 +393,7 @@ Obtains entries within a range in this container, including the entry at the sta
**Return value** **Return value**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -413,7 +413,7 @@ Clears all entries in this container and sets its length to **0**. ...@@ -413,7 +413,7 @@ Clears all entries in this container and sets its length to **0**.
**Return value** **Return value**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -436,7 +436,7 @@ Clones this container and returns a copy. The modification to the copy does not ...@@ -436,7 +436,7 @@ Clones this container and returns a copy. The modification to the copy does not
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -459,7 +459,7 @@ Obtains the capacity of this container. ...@@ -459,7 +459,7 @@ Obtains the capacity of this container.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -482,7 +482,7 @@ Converts this container into an array. ...@@ -482,7 +482,7 @@ Converts this container into an array.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -505,7 +505,7 @@ Checks whether this container is empty (contains no entries). ...@@ -505,7 +505,7 @@ Checks whether this container is empty (contains no entries).
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -528,7 +528,7 @@ Increases the capacity of this container. ...@@ -528,7 +528,7 @@ Increases the capacity of this container.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -546,7 +546,7 @@ Trims the capacity of this container into its current length. ...@@ -546,7 +546,7 @@ Trims the capacity of this container into its current length.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -569,7 +569,7 @@ Uses commas (,) to concatenate entries in this container into a string. ...@@ -569,7 +569,7 @@ Uses commas (,) to concatenate entries in this container into a string.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -592,7 +592,7 @@ Copies entries in this container into an array to overwrite elements of the same ...@@ -592,7 +592,7 @@ Copies entries in this container into an array to overwrite elements of the same
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -616,7 +616,7 @@ Obtains the first entry in this container. ...@@ -616,7 +616,7 @@ Obtains the first entry in this container.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -639,7 +639,7 @@ Obtains the last entry in this container. ...@@ -639,7 +639,7 @@ Obtains the last entry in this container.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -669,7 +669,7 @@ Searches for an entry backward from the specified position index and returns the ...@@ -669,7 +669,7 @@ Searches for an entry backward from the specified position index and returns the
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -700,7 +700,7 @@ Searches for an entry forward from the specified position index and returns the ...@@ -700,7 +700,7 @@ Searches for an entry forward from the specified position index and returns the
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -724,7 +724,7 @@ Sets a new length for this container. ...@@ -724,7 +724,7 @@ Sets a new length for this container.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -754,7 +754,7 @@ Obtains an entry at the specified position in this container. ...@@ -754,7 +754,7 @@ Obtains an entry at the specified position in this container.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -783,7 +783,7 @@ Replaces an entry at the specified position in this container with a given entry ...@@ -783,7 +783,7 @@ Replaces an entry at the specified position in this container with a given entry
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -806,7 +806,7 @@ Obtains an iterator. Each item of the iterator is a JavaScript object. ...@@ -806,7 +806,7 @@ Obtains an iterator. Each item of the iterator is a JavaScript object.
**Example** **Example**
``` ```ts
let vector = new Vector(); let vector = new Vector();
vector.add(2); vector.add(2);
vector.add(4); vector.add(4);
...@@ -815,14 +815,14 @@ vector.add(4); ...@@ -815,14 +815,14 @@ vector.add(4);
// Method 1: // Method 1:
for (let item of vector) { for (let item of vector) {
console.log(item); console.log("value:" + item);
} }
// Method 2: // Method 2:
let iter = vector[Symbol.iterator](); let iter = vector[Symbol.iterator]();
let temp = iter.next().value; let temp = iter.next().value;
while(temp != undefined) { while(temp != undefined) {
console.log(temp); console.log("value:" + temp);
temp = iter.next().value; temp = iter.next().value;
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册