diff --git a/en/application-dev/reference/apis/js-apis-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md index 341295a167878f6c3696efe01f15a29415f91cd8..2ec941798d034038f817f4b0d7eb9776f1881af8 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 8d9a9c1b42bef6ce74fdfb21a8033b80e68c1868..5cc9d544618a32b7c3682a97eba5853457ca8246 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 d1ac45e3bd10590be109ded2095405e4dee962de..940b60480b3ce64b5c9c26b3357709f85fb9c161 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 85bbfa2719412099c1d051de61b3c39363872b27..3f704fe3423df4c11d79bae53af5c164e0c4f461 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 5ac480761ba58f22e2f120aeaa0aca58faed366d..8131b1fad3e0662eba2decc651cf5ea43bc33814 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 4a900d9f5476216ae7e98a0df9d762119753ad36..d0bea7225b4d6774687799ada78aa6c42d1562d2 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 73737f14b6078445e1f67762ca43a86a22804dbe..90feda86289277ba13c78db3623c8078048034ef 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 0b839a5a0baae3fa58e4592485c3b9e959183530..fc1370ca4c7c627ec3f6b07b8daa6770fe6a0783 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 237dfe4234e2eb9049e419bfe94d051c2aab893e..cb554fea8037fa029e2d786c7dd30f742ebecd75 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 a31a72649d0e0ede56771f3fa6c9bf4d25bbefe7..79a0f068368235e634a29efc871581f2621a621f 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 b1e10e9478bc3335b30cd85498f9feb81b07bfd1..78c337c3367e080e856cb5dc2e05a74aca28e4a0 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 7914e5bd409d29b3bcae14653aaa6bd8dd5f6f9c..ab107c77710f72d59249a16a5a2acd3239afbebb 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 6e50abcf23c7cf2c3a77e6029244a0078edd1562..4cdd36dbd929a39e64a0e35d23417d091d73ace6 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 5dd8e49bb0c2467b2885784b9c1281f61e46a003..79934c5d08c61aad18409edb89670ebfed45637b 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>