Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
420c0978
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
420c0978
编写于
2月 28, 2023
作者:
B
bi-hu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modify the problem of printing test cases of the foreach interface in containers to 3.1-Release
Signed-off-by:
N
bi-hu
<
bihu@huawei.com
>
上级
bfeca52d
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
27 addition
and
53 deletion
+27
-53
zh-cn/application-dev/reference/apis/js-apis-arraylist.md
zh-cn/application-dev/reference/apis/js-apis-arraylist.md
+4
-6
zh-cn/application-dev/reference/apis/js-apis-deque.md
zh-cn/application-dev/reference/apis/js-apis-deque.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-hashmap.md
zh-cn/application-dev/reference/apis/js-apis-hashmap.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-hashset.md
zh-cn/application-dev/reference/apis/js-apis-hashset.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md
.../application-dev/reference/apis/js-apis-lightweightmap.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-lightweightset.md
.../application-dev/reference/apis/js-apis-lightweightset.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-list.md
zh-cn/application-dev/reference/apis/js-apis-list.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-plainarray.md
zh-cn/application-dev/reference/apis/js-apis-plainarray.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-queue.md
zh-cn/application-dev/reference/apis/js-apis-queue.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-stack.md
zh-cn/application-dev/reference/apis/js-apis-stack.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-treemap.md
zh-cn/application-dev/reference/apis/js-apis-treemap.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-treeset.md
zh-cn/application-dev/reference/apis/js-apis-treeset.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-vector.md
zh-cn/application-dev/reference/apis/js-apis-vector.md
+11
-35
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-arraylist.md
浏览文件 @
420c0978
...
...
@@ -319,11 +319,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
;
});
```
...
...
@@ -360,7 +358,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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-deque.md
浏览文件 @
420c0978
...
...
@@ -207,7 +207,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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-hashmap.md
浏览文件 @
420c0978
...
...
@@ -374,7 +374,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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-hashset.md
浏览文件 @
420c0978
...
...
@@ -227,7 +227,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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md
浏览文件 @
420c0978
...
...
@@ -581,7 +581,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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-lightweightset.md
浏览文件 @
420c0978
...
...
@@ -481,7 +481,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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
浏览文件 @
420c0978
...
...
@@ -495,7 +495,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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-list.md
浏览文件 @
420c0978
...
...
@@ -404,7 +404,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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-plainarray.md
浏览文件 @
420c0978
...
...
@@ -481,7 +481,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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-queue.md
浏览文件 @
420c0978
...
...
@@ -159,7 +159,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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-stack.md
浏览文件 @
420c0978
...
...
@@ -191,7 +191,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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-treemap.md
浏览文件 @
420c0978
...
...
@@ -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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-treeset.md
浏览文件 @
420c0978
...
...
@@ -393,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
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-vector.md
浏览文件 @
420c0978
# 线性容器Vector
>  **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
Vector是一种线性数据结构,底层基于数组实现。当Vector的内存用尽时,会自动分配更大的连续内存区,将原先的元素复制到新的内存区,并释放旧的内存区。使用Vector能够高效快速地访问元素。
Vector和
[
ArrayList
](
js-apis-arraylist.md
)
相似,都是基于数组实现,但Vector提供了更多操作数组的接口。它们都可以动态调整容量,但Vector每次扩容增加1倍,ArrayList只扩容0.5倍。
**推荐使用场景:**
当数据量大时,一般使用Vector来存取数据。
>  **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
ts
...
...
@@ -247,7 +248,7 @@ remove(element: T): boolean
| -------- | -------- |
| boolean | 删除成功返回true,否则返回false。 |
**
返回值
:**
**
示例
:**
```
ts
let
vector
=
new
Vector
();
...
...
@@ -318,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
)
=>
{
// 用户操作逻辑根据实际场景进行添加。
return
value
;
});
```
...
...
@@ -359,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
);
});
```
...
...
@@ -419,7 +418,7 @@ subVector(fromIndex: number, toIndex: number): Vector<T>
| -------- | -------- |
| Vector
<
T
>
| 返回Vector对象实例。 |
**
返回值
:**
**
示例
:**
```
ts
let
vector
=
new
Vector
();
...
...
@@ -441,7 +440,7 @@ clear(): void
**系统能力:**
SystemCapability.Utils.Lang
**
返回值
:**
**
示例
:**
```
ts
let
vector
=
new
Vector
();
...
...
@@ -636,18 +635,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
...
...
@@ -841,17 +828,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
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录