From 8f8c10c6b837c6eb23e9eae057a4dd7d885253fb Mon Sep 17 00:00:00 2001 From: Gloria Date: Mon, 6 Mar 2023 16:54:55 +0800 Subject: [PATCH] Update docs against 15343+14417 Signed-off-by: wusongqing --- .../reference/apis/js-apis-arraylist.md | 10 ++-- .../reference/apis/js-apis-deque.md | 2 +- .../reference/apis/js-apis-hashmap.md | 2 +- .../reference/apis/js-apis-hashset.md | 2 +- .../reference/apis/js-apis-lightweightmap.md | 2 +- .../reference/apis/js-apis-lightweightset.md | 2 +- .../reference/apis/js-apis-linkedlist.md | 2 +- .../reference/apis/js-apis-list.md | 2 +- .../reference/apis/js-apis-plainarray.md | 2 +- .../reference/apis/js-apis-queue.md | 2 +- .../reference/apis/js-apis-stack.md | 2 +- .../reference/apis/js-apis-treemap.md | 10 ++-- .../reference/apis/js-apis-treeset.md | 9 ++-- .../reference/apis/js-apis-vector.md | 47 +++++-------------- 14 files changed, 35 insertions(+), 61 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md index 341295a167..2ec941798d 100644 --- a/en/application-dev/reference/apis/js-apis-arraylist.md +++ b/en/application-dev/reference/apis/js-apis-arraylist.md @@ -320,11 +320,9 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.replaceAllElements((value: number, index: number)=> { - return value = 2 * value; -}); -arrayList.replaceAllElements((value: number, index: number) => { - return value = value - 2; +arrayList.replaceAllElements((value) => { + // Add the user operation logic based on the actual scenario. + return value; }); ``` @@ -361,7 +359,7 @@ arrayList.add(4); arrayList.add(5); arrayList.add(4); arrayList.forEach((value, index) => { - console.log("value:" + value, index); + console.log("value:" + value, "index:" + index); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-deque.md b/en/application-dev/reference/apis/js-apis-deque.md index 8d9a9c1b42..5cc9d54461 100644 --- a/en/application-dev/reference/apis/js-apis-deque.md +++ b/en/application-dev/reference/apis/js-apis-deque.md @@ -208,7 +208,7 @@ deque.insertEnd(4); deque.insertFront(5); deque.insertEnd(4); deque.forEach((value, index) => { - console.log("value:" + value, index); + console.log("value:" + value, "index:" + index); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-hashmap.md b/en/application-dev/reference/apis/js-apis-hashmap.md index d1ac45e3bd..940b60480b 100644 --- a/en/application-dev/reference/apis/js-apis-hashmap.md +++ b/en/application-dev/reference/apis/js-apis-hashmap.md @@ -375,7 +375,7 @@ let hashMap = new HashMap(); hashMap.set("sdfs", 123); hashMap.set("dfsghsf", 357); hashMap.forEach((value, key) => { - console.log("value:" + value, key); + console.log("value:" + value, "key:" + key); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-hashset.md b/en/application-dev/reference/apis/js-apis-hashset.md index 85bbfa2719..3f704fe342 100644 --- a/en/application-dev/reference/apis/js-apis-hashset.md +++ b/en/application-dev/reference/apis/js-apis-hashset.md @@ -228,7 +228,7 @@ let hashSet = new HashSet(); hashSet.add("sdfs"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.forEach((value, key) => { - console.log("value:" + value, key); + console.log("value:" + value, "key:" + key); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-lightweightmap.md b/en/application-dev/reference/apis/js-apis-lightweightmap.md index 5ac480761b..8131b1fad3 100644 --- a/en/application-dev/reference/apis/js-apis-lightweightmap.md +++ b/en/application-dev/reference/apis/js-apis-lightweightmap.md @@ -582,7 +582,7 @@ let lightWeightMap = new LightWeightMap(); lightWeightMap.set("sdfs", 123); lightWeightMap.set("dfsghsf", 357); lightWeightMap.forEach((value, key) => { - console.log("value:" + value, key); + console.log("value:" + value, "key:" + key); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-lightweightset.md b/en/application-dev/reference/apis/js-apis-lightweightset.md index 4a900d9f54..d0bea7225b 100644 --- a/en/application-dev/reference/apis/js-apis-lightweightset.md +++ b/en/application-dev/reference/apis/js-apis-lightweightset.md @@ -482,7 +482,7 @@ let lightWeightSet = new LightWeightSet(); lightWeightSet.add("sdfs"); lightWeightSet.add("dfsghsf"); lightWeightSet.forEach((value, key) => { - console.log("value:" + value, key); + console.log("value:" + value, "key:" + key); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-linkedlist.md b/en/application-dev/reference/apis/js-apis-linkedlist.md index 73737f14b6..90feda8628 100644 --- a/en/application-dev/reference/apis/js-apis-linkedlist.md +++ b/en/application-dev/reference/apis/js-apis-linkedlist.md @@ -496,7 +496,7 @@ linkedList.add(4); linkedList.add(5); linkedList.add(4); linkedList.forEach((value, index) => { - console.log("value:" + value, index); + console.log("value:" + value, "index:" + index); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-list.md b/en/application-dev/reference/apis/js-apis-list.md index 0b839a5a0b..fc1370ca4c 100644 --- a/en/application-dev/reference/apis/js-apis-list.md +++ b/en/application-dev/reference/apis/js-apis-list.md @@ -405,7 +405,7 @@ list.add(4); list.add(5); list.add(4); list.forEach((value, index) => { - console.log("value: " + value, index); + console.log("value:" + value, "index:" + index); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-plainarray.md b/en/application-dev/reference/apis/js-apis-plainarray.md index 237dfe4234..cb554fea80 100644 --- a/en/application-dev/reference/apis/js-apis-plainarray.md +++ b/en/application-dev/reference/apis/js-apis-plainarray.md @@ -482,7 +482,7 @@ let plainArray = new PlainArray(); plainArray.add(1, "sddfhf"); plainArray.add(2, "sffdfhf"); plainArray.forEach((value, index) => { - console.log("value:" + value, index); + console.log("value:" + value, "index:" + index); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-queue.md b/en/application-dev/reference/apis/js-apis-queue.md index a31a72649d..79a0f06836 100644 --- a/en/application-dev/reference/apis/js-apis-queue.md +++ b/en/application-dev/reference/apis/js-apis-queue.md @@ -160,7 +160,7 @@ queue.add(4); queue.add(5); queue.add(4); queue.forEach((value, index) => { - console.log("value:" + value, index); + console.log("value:" + value, "index:" + index); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-stack.md b/en/application-dev/reference/apis/js-apis-stack.md index b1e10e9478..78c337c336 100644 --- a/en/application-dev/reference/apis/js-apis-stack.md +++ b/en/application-dev/reference/apis/js-apis-stack.md @@ -192,7 +192,7 @@ stack.push(4); stack.push(5); stack.push(4); stack.forEach((value, index) => { - console.log("value:" + value, index); + console.log("value:" + value, "index:" + index); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-treemap.md b/en/application-dev/reference/apis/js-apis-treemap.md index 7914e5bd40..ab107c7771 100644 --- a/en/application-dev/reference/apis/js-apis-treemap.md +++ b/en/application-dev/reference/apis/js-apis-treemap.md @@ -1,9 +1,5 @@ # Nonlinear Container TreeMap -> **NOTE** -> -> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. - **TreeMap** stores key-value (KV) pairs. Each key must be unique and have only one value. **TreeMap** is implemented using a red-black tree, which is a binary search tree where keys are stored in sorted order for efficient insertion and removal. @@ -12,6 +8,10 @@ Recommended use case: Use **TreeMap** when you need to store KV pairs in sorted order. +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## Modules to Import ```ts @@ -490,7 +490,7 @@ let treeMap = new TreeMap(); treeMap.set("sdfs", 123); treeMap.set("dfsghsf", 357); treeMap.forEach((value, key) => { - console.log("value:" + value, key); + console.log("value:" + value, "key:" + key); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-treeset.md b/en/application-dev/reference/apis/js-apis-treeset.md index 6e50abcf23..4cdd36dbd9 100644 --- a/en/application-dev/reference/apis/js-apis-treeset.md +++ b/en/application-dev/reference/apis/js-apis-treeset.md @@ -1,8 +1,5 @@ # Nonlinear Container TreeSet -> **NOTE** -> -> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. **TreeSet** is implemented based on **[TreeMap](js-apis-treemap.md)**. In **TreeSet**, only **value** objects are processed. **TreeSet** can be used to store values, each of which must be unique. @@ -10,6 +7,10 @@ Recommended use case: Use **TreeSet** when you need to store data in sorted order. +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## Modules to Import ```ts @@ -392,7 +393,7 @@ let treeSet = new TreeSet(); treeSet.add("sdfs"); treeSet.add("dfsghsf"); treeSet.forEach((value, key) => { - console.log("value:" + value, key) + console.log("value:" + value, "key:" + key); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-vector.md b/en/application-dev/reference/apis/js-apis-vector.md index 5dd8e49bb0..79934c5d08 100644 --- a/en/application-dev/reference/apis/js-apis-vector.md +++ b/en/application-dev/reference/apis/js-apis-vector.md @@ -1,15 +1,15 @@ # Linear Container Vector -> **NOTE** -> -> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. - **Vector** is a linear data structure that is implemented based on arrays. When the memory of a vector is used up, a larger contiguous memory area is automatically allocated, all the elements are copied to the new memory area, and the current memory area is reclaimed. **Vector** can be used to efficiently access elements. Both **Vector** and **[ArrayList](js-apis-arraylist.md)** are implemented based on arrays, but **Vector** provides more interfaces for operating the arrays. Both of them can dynamically adjust the capacity. **Vector** doubles the capacity each time, whereas **ArrayList** increases the capacity by 50%. **Recommended use case**: Use **Vector** when the data volume is large. +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## Modules to Import ```ts @@ -248,7 +248,7 @@ Removes the first occurrence of the specified element from this container. | -------- | -------- | | boolean | Returns **true** if the element is removed successfully; returns **false** otherwise.| -**Return value** +**Example** ```ts let vector = new Vector(); @@ -319,11 +319,9 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.replaceAllElements((value: number, index: number) => { - return value = 2 * value; -}); -vector.replaceAllElements((value: number, index: number) => { - return value = value - 2; +vector.replaceAllElements((value) => { + // Add the user operation logic based on the actual scenario. + return value; }); ``` @@ -360,7 +358,7 @@ vector.add(4); vector.add(5); vector.add(4); vector.forEach((value, index) => { - console.log("value:" + value, index) + console.log("value:" + value, "index:" + index); }); ``` @@ -420,7 +418,7 @@ Obtains elements within a range in this container, including the element at the | -------- | -------- | | Vector<T> | New **Vector** instance obtained.| -**Return value** +**Example** ```ts let vector = new Vector(); @@ -442,7 +440,7 @@ Clears all elements in this container and sets its length to **0**. **System capability**: SystemCapability.Utils.Lang -**Return value** +**Example** ```ts let vector = new Vector(); @@ -637,18 +635,6 @@ Copies elements in this container into an array to overwrite elements of the sam | -------- | -------- | -------- | -------- | | array | Array<T> | Yes| Array to which the elements in the container will be copied.| -**Example** - -```ts -let vector = new Vector(); -vector.add(2); -vector.add(4); -vector.add(5); -vector.add(4); -let array = ["a", "b", "c", "d", "e", "f"]; -let result = vector.copyToArray(array); -``` - ### getFirstElement getFirstElement(): T @@ -842,17 +828,6 @@ Replaces an element at the specified position in this container with a given ele | -------- | -------- | | T | New element.| -**Example** - - ```ts - let vector = new Vector(); - vector.add(2); - vector.add(4); - vector.add(5); - vector.add(4); - let result = vector.set(2, "A"); - ``` - ### [Symbol.iterator] [Symbol.iterator]\(): IterableIterator<T> -- GitLab