diff --git a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md
index c83750888acc342ac51275695a7d24060a716ad5..9dcc2325a08e342f8acdf89f78a7eb2bd302401a 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md
@@ -404,11 +404,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) => {
+ // 用户操作逻辑根据实际场景进行添加。
+ return value;
});
```
@@ -453,7 +451,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);
});
```
@@ -796,14 +794,14 @@ arrayList.add(4);
// 使用方法一:
for (let item of arrayList) {
- console.log(`value:${item}`);
+ console.log(`value:${item}`);
}
// 使用方法二:
let iter = arrayList[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(`value:${temp}`);
- temp = iter.next().value;
+ console.log(`value:${temp}`);
+ temp = iter.next().value;
}
```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-deque.md b/zh-cn/application-dev/reference/apis/js-apis-deque.md
index 715851dcf78ed465e3cc06ad8698b2587bc54aa1..4d12db310a1d9bed9cdcf9f1a84ec296f3b2051a 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-deque.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-deque.md
@@ -270,7 +270,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/zh-cn/application-dev/reference/apis/js-apis-hashmap.md b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md
index 58af2a38a1fbcbb7df92351d630ffc5994b0c74e..caf15684fdf99d8ca47b23e532811ae492a52989 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md
@@ -484,7 +484,7 @@ let hashMap = new HashMap();
hashMap.set("sparrow", 123);
hashMap.set("gull", 357);
hashMap.forEach((value, key) => {
- console.log("value:" + value, key);
+ console.log("value:" + value, "key:" + key);
});
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashset.md b/zh-cn/application-dev/reference/apis/js-apis-hashset.md
index b5b4028d55c862bd0eb8fe3adbca62034322c6cd..36fed1ef17a3ffb0dd2b39d4f04a209650e7e88c 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-hashset.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-hashset.md
@@ -305,7 +305,7 @@ let hashSet = new HashSet();
hashSet.add("sparrow");
hashSet.add("squirrel");
hashSet.forEach((value, key) => {
- console.log("value:" + value, key);
+ console.log("value:" + value, "key:" + key);
});
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md
index 3f7df990f645d32d0152e93dd16473662826743a..64dd301c529ea01aed122355da8fb26242d5d5a2 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md
@@ -747,7 +747,7 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("sparrow", 123);
lightWeightMap.set("gull", 357);
lightWeightMap.forEach((value, key) => {
- console.log("value:" + value, key);
+ console.log("value:" + value, "key:" + key);
});
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md
index 7a9eaabb026f8513589b8d5854ebc4cc06522c1b..7de14cbeef300fbad13e1a49af32ad098ca167e5 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md
@@ -611,7 +611,7 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet.add("sparrow");
lightWeightSet.add("gull");
lightWeightSet.forEach((value, key) => {
- console.log("value:" + value, key);
+ console.log("value:" + value, "key:" + key);
});
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
index 332740e7b5c1915dac8a257051c8196a6fffa472..0dacc445d76d0c16ee6239f890bebd6177532c6d 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
@@ -635,7 +635,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/zh-cn/application-dev/reference/apis/js-apis-list.md b/zh-cn/application-dev/reference/apis/js-apis-list.md
index 3acc747e39ed657ecf90916023c73ff95998b88e..340e534933ea1233516c9fa77589eb15dc32f5fa 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-list.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-list.md
@@ -506,7 +506,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/zh-cn/application-dev/reference/apis/js-apis-plainarray.md b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md
index 61eaf7a1f035fabaccf9e265360dc8dc4010c838..6b311ca0809802d5d8ab9d3013ea76f4ec0e457a 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md
@@ -621,7 +621,7 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
plainArray.forEach((value, index) => {
- console.log("value:" + value, index);
+ console.log("value:" + value, "index:" + index);
});
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-queue.md b/zh-cn/application-dev/reference/apis/js-apis-queue.md
index 16de01a60ca82cc5c37435924b2dd7f1fcbe9c8d..1e9383532964b92ae027a154f7dcf7d99eff2b25 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-queue.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-queue.md
@@ -201,7 +201,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/zh-cn/application-dev/reference/apis/js-apis-stack.md b/zh-cn/application-dev/reference/apis/js-apis-stack.md
index bd30e4fc90703ec49f4392afc77e230064f9aefa..a3d0fc0a094835df6d5e0694e94ee1068a16692c 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-stack.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-stack.md
@@ -239,7 +239,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/zh-cn/application-dev/reference/apis/js-apis-treemap.md b/zh-cn/application-dev/reference/apis/js-apis-treemap.md
index 99fabdacb010daf46b1a27fac7c5cb854ea59d42..cd780e9e1fe63c7f9f159dfc779c1821a825fc3f 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-treemap.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-treemap.md
@@ -636,7 +636,7 @@ let treeMap = new TreeMap();
treeMap.set("sparrow", 123);
treeMap.set("gull", 357);
treeMap.forEach((value, key) => {
- console.log("value:" + value, key);
+ console.log("value:" + value, "key:" + key);
});
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-treeset.md b/zh-cn/application-dev/reference/apis/js-apis-treeset.md
index 68308be6ea45a4fd308249862805fb51df018f41..e90aabc45e5f3725274881f7859cedfecd3a89c2 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-treeset.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-treeset.md
@@ -508,7 +508,7 @@ let treeSet = new TreeSet();
treeSet.add("sparrow");
treeSet.add("gull");
treeSet.forEach((value, key) => {
- console.log("value:" + value, key)
+ console.log("value:" + value, "key:" + key);
});
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-vector.md b/zh-cn/application-dev/reference/apis/js-apis-vector.md
index dba118240389f2cd6df315f1410fb765fd8ab7a6..cecf717fcce6254aeea9753c4682f4957995264c 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-vector.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-vector.md
@@ -1,16 +1,19 @@
# @ohos.util.Vector (线性容器Vector)
-> **说明:**
-> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
-
Vector是一种线性数据结构,底层基于数组实现。当Vector的内存用尽时,会自动分配更大的连续内存区,将原先的元素复制到新的内存区,并释放旧的内存区。使用Vector能够高效快速地访问元素。
Vector和[ArrayList](js-apis-arraylist.md)相似,都是基于数组实现,但Vector提供了更多操作数组的接口。它们都可以动态调整容量,但Vector每次扩容增加1倍,ArrayList只扩容0.5倍。
**推荐使用场景:** 当数据量大时,一般使用Vector来存取数据。
-文档中存在泛型的使用,涉及以下泛型标记符:
-- T: Type, 类
+文档中存在泛型的使用,涉及以下泛型标记符:
+- T:Type,类
+
+> **说明:**
+>
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+>
+> API version 9开始,该接口不再维护,推荐使用接口['@ohos.util.ArrayList'](js-apis-arraylist.md)。
## 导入模块
@@ -250,7 +253,7 @@ remove(element: T): boolean
| -------- | -------- |
| boolean | 删除成功返回true,否则返回false。 |
-**返回值:**
+**示例:**
```ts
let vector = new Vector();
@@ -319,11 +322,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) => {
+ // 用户操作逻辑根据实际场景进行添加。
+ return value;
});
```
@@ -360,7 +361,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 +421,7 @@ subVector(fromIndex: number, toIndex: number): Vector<T>
| -------- | -------- |
| Vector<T> | 返回Vector对象实例。 |
-**返回值:**
+**示例:**
```ts
let vector = new Vector();
@@ -443,7 +444,7 @@ clear(): void
**系统能力:** SystemCapability.Utils.Lang
-**返回值:**
+**示例:**
```ts
let vector = new Vector();
@@ -638,18 +639,6 @@ copyToArray(array: Array<T>): void
| -------- | -------- | -------- | -------- |
| array | Array<T> | 是 | 指定数组。 |
-**示例:**
-
-```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
@@ -843,17 +832,6 @@ set(index: number, element: T): T
| -------- | -------- |
| T | 返回替换后的元素。 |
-**示例:**
-
- ```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>