Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
0e462d7b
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
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看板
提交
0e462d7b
编写于
8月 24, 2023
作者:
J
jiangkai43
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
容器类示例代码适配适配ArkTS的迁移
Signed-off-by:
N
jiangkai43
<
jiangkai43@huawei.com
>
上级
133fc8e1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
102 addition
and
95 deletion
+102
-95
zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
+41
-32
zh-cn/application-dev/reference/apis/js-apis-list.md
zh-cn/application-dev/reference/apis/js-apis-list.md
+37
-32
zh-cn/application-dev/reference/apis/js-apis-plainarray.md
zh-cn/application-dev/reference/apis/js-apis-plainarray.md
+24
-31
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
浏览文件 @
0e462d7b
...
...
@@ -19,7 +19,7 @@ LinkedList和[ArrayList](js-apis-arraylist.md)相比,插入数据效率LinkedL
## 导入模块
```
ts
import
LinkedList
from
'
@ohos.util.LinkedList
'
;
import
LinkedList
from
'
@ohos.util.LinkedList
'
;
```
## LinkedList
...
...
@@ -53,7 +53,7 @@ LinkedList的构造函数。
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
string
|
number
|
boolean
|
object
>
=
new
LinkedList
();
```
...
...
@@ -88,12 +88,16 @@ add(element: T): boolean
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
string
|
number
|
boolean
|
object
>
=
new
LinkedList
();
let
result
=
linkedList
.
add
(
"
a
"
);
let
result1
=
linkedList
.
add
(
1
);
let
b
=
[
1
,
2
,
3
];
let
result2
=
linkedList
.
add
(
b
);
let
c
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
class
C
{
name
:
string
=
''
age
:
string
=
''
}
let
c
:
C
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
let
result3
=
linkedList
.
add
(
c
);
let
result4
=
linkedList
.
add
(
false
);
```
...
...
@@ -123,12 +127,16 @@ addFirst(element: T): void
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
string
|
number
|
boolean
|
object
>
=
new
LinkedList
();
linkedList
.
addFirst
(
"
a
"
);
linkedList
.
addFirst
(
1
);
let
b
=
[
1
,
2
,
3
];
linkedList
.
addFirst
(
b
);
let
c
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
class
C
{
name
:
string
=
''
age
:
string
=
''
}
let
c
:
C
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
linkedList
.
addFirst
(
c
);
linkedList
.
addFirst
(
false
);
```
...
...
@@ -160,7 +168,7 @@ insert(index: number, element: T): void
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
string
|
number
|
boolean
|
object
>
=
new
LinkedList
();
linkedList
.
insert
(
0
,
"
A
"
);
linkedList
.
insert
(
1
,
0
);
linkedList
.
insert
(
2
,
true
);
...
...
@@ -197,7 +205,7 @@ has(element: T): boolean
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
string
>
=
new
LinkedList
();
linkedList
.
add
(
"
squirrel
"
);
let
result
=
linkedList
.
has
(
"
squirrel
"
);
```
...
...
@@ -233,7 +241,7 @@ get(index: number): T
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -275,7 +283,7 @@ getLastIndexOf(element: T): number
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -317,7 +325,7 @@ getIndexOf(element: T): number
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -360,7 +368,7 @@ removeByIndex(index: number): T
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -395,7 +403,7 @@ removeFirst(): T
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -430,7 +438,7 @@ removeLast(): T
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -470,7 +478,7 @@ remove(element: T): boolean
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -511,7 +519,7 @@ removeFirstFound(element: T): boolean
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -552,7 +560,7 @@ removeLastFound(element: T): boolean
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -585,7 +593,7 @@ clone(): LinkedList<T>
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -628,13 +636,13 @@ callbackfn的参数说明:
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
linkedList
.
add
(
4
);
linkedList
.
forEach
((
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
"
index:
"
+
index
);
linkedList
.
forEach
((
value
:
number
,
index
:
number
)
=>
{
console
.
log
(
"
value:
"
+
value
,
"
index:
"
+
index
);
});
```
...
...
@@ -657,7 +665,7 @@ clear(): void
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -698,7 +706,7 @@ set(index: number, element: T): T
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
|
string
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -730,7 +738,7 @@ convertToArray(): Array<T>
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -763,7 +771,7 @@ getFirst(): T
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -796,7 +804,7 @@ getLast(): T
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
...
...
@@ -829,22 +837,23 @@ let result = linkedList.getLast();
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
let
linkedList
:
LinkedList
<
number
>
=
new
LinkedList
();
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
linkedList
.
add
(
4
);
// 使用方法一:
for
(
let
item
of
linkedList
)
{
let
items
=
Array
.
from
(
linkedList
)
for
(
let
item
of
items
)
{
console
.
log
(
"
value:
"
+
item
);
}
// 使用方法二:
let
iter
=
linkedList
[
Symbol
.
iterator
]();
let
temp
=
iter
.
next
()
.
value
;
while
(
temp
!=
undefined
)
{
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
()
.
value
;
let
temp
=
iter
.
next
();
while
(
!
temp
.
done
)
{
console
.
log
(
"
value:
"
+
temp
.
value
);
temp
=
iter
.
next
();
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-list.md
浏览文件 @
0e462d7b
...
...
@@ -51,7 +51,7 @@ List的构造函数。
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
string
|
number
|
boolean
|
object
>
=
new
List
();
```
...
...
@@ -86,12 +86,16 @@ add(element: T): boolean
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
string
|
number
|
boolean
|
object
>
=
new
List
();
let
result1
=
list
.
add
(
"
a
"
);
let
result2
=
list
.
add
(
1
);
let
b
=
[
1
,
2
,
3
];
let
result3
=
list
.
add
(
b
);
let
c
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
class
C
{
name
:
string
=
''
age
:
string
=
''
}
let
c
:
C
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
let
result4
=
list
.
add
(
c
);
let
result5
=
list
.
add
(
false
);
```
...
...
@@ -123,7 +127,7 @@ insert(element: T, index: number): void
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
string
|
number
|
boolean
>
=
new
List
();
list
.
insert
(
"
A
"
,
0
);
list
.
insert
(
0
,
1
);
list
.
insert
(
true
,
2
);
...
...
@@ -160,7 +164,7 @@ has(element: T): boolean
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
string
>
=
new
List
();
list
.
add
(
"
squirrel
"
);
let
result
=
list
.
has
(
"
squirrel
"
);
```
...
...
@@ -196,7 +200,7 @@ get(index: number): T
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -238,7 +242,7 @@ getLastIndexOf(element: T): number
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -280,7 +284,7 @@ getIndexOf(element: T): number
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -322,11 +326,11 @@ equal(obj: Object): boolean
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
let
obj
=
new
List
();
let
obj
:
List
<
number
>
=
new
List
();
obj
.
add
(
2
);
obj
.
add
(
4
);
obj
.
add
(
5
);
...
...
@@ -365,7 +369,7 @@ removeByIndex(index: number): T
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -405,7 +409,7 @@ remove(element: T): boolean
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -448,12 +452,12 @@ callbackfn的参数说明:
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
list
.
add
(
4
);
list
.
replaceAllElements
((
value
)
=>
{
list
.
replaceAllElements
((
value
:
number
)
=>
{
// 用户操作逻辑根据实际场景进行添加。
return
value
;
});
...
...
@@ -494,13 +498,13 @@ callbackfn的参数说明:
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
list
.
add
(
4
);
list
.
forEach
((
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
"
index:
"
+
index
);
list
.
forEach
((
value
:
number
,
index
:
number
)
=>
{
console
.
log
(
"
value:
"
+
value
,
"
index:
"
+
index
);
});
```
...
...
@@ -536,7 +540,7 @@ comparator的参数说明:
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -578,7 +582,7 @@ getSubList(fromIndex: number, toIndex: number): List<T>
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -605,7 +609,7 @@ clear(): void
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -646,7 +650,7 @@ set(index: number, element: T): T
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
|
string
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -679,7 +683,7 @@ convertToArray(): Array<T>
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -712,7 +716,7 @@ isEmpty(): boolean
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -745,7 +749,7 @@ getFirst(): T
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -778,7 +782,7 @@ getLast(): T
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
...
...
@@ -811,22 +815,23 @@ let result = list.getLast();
**示例:**
```
ts
let
list
=
new
List
();
let
list
:
List
<
number
>
=
new
List
();
list
.
add
(
2
);
list
.
add
(
4
);
list
.
add
(
5
);
list
.
add
(
4
);
// 使用方法一:
for
(
let
item
of
list
)
{
console
.
log
(
"
value:
"
+
item
);
let
items
=
Array
.
from
(
list
)
for
(
let
item
of
items
)
{
console
.
log
(
"
value:
"
+
item
);
}
// 使用方法二:
let
iter
=
list
[
Symbol
.
iterator
]();
let
temp
=
iter
.
next
()
.
value
;
while
(
temp
!=
undefined
)
{
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
()
.
value
;
let
temp
=
iter
.
next
();
while
(
!
temp
.
done
)
{
console
.
log
(
"
value:
"
+
temp
.
value
);
temp
=
iter
.
next
();
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-plainarray.md
浏览文件 @
0e462d7b
...
...
@@ -53,7 +53,7 @@ PlainArray的构造函数。
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
```
...
...
@@ -82,7 +82,7 @@ isEmpty(): boolean
**示例:**
```
ts
const
plainArray
=
new
PlainArray
();
const
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
let
result
=
plainArray
.
isEmpty
();
```
...
...
@@ -118,7 +118,7 @@ has(key: number): boolean
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
let
result
=
plainArray
.
has
(
1
);
```
...
...
@@ -155,7 +155,7 @@ get(key: number): T
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
get
(
1
);
...
...
@@ -193,7 +193,7 @@ getIndexOfKey(key: number): number
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
getIndexOfKey
(
2
);
...
...
@@ -231,7 +231,7 @@ getIndexOfValue(value: T): number
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
getIndexOfValue
(
"
squirrel
"
);
...
...
@@ -269,7 +269,7 @@ getKeyAt(index: number): number
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
getKeyAt
(
1
);
...
...
@@ -307,7 +307,7 @@ getValueAt(index: number): T
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
getValueAt
(
1
);
...
...
@@ -338,7 +338,7 @@ clone(): PlainArray<T>
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
newPlainArray
=
plainArray
.
clone
();
...
...
@@ -371,7 +371,7 @@ add(key: number, value: T): void
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
```
...
...
@@ -407,7 +407,7 @@ remove(key: number): T
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
remove
(
2
);
...
...
@@ -445,7 +445,7 @@ removeAt(index: number): T
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
removeAt
(
1
);
...
...
@@ -485,7 +485,7 @@ removeRangeFrom(index: number, size: number): number
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
removeRangeFrom
(
1
,
3
);
...
...
@@ -519,7 +519,7 @@ setValueAt(index: number, value: T): void
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
|
number
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
plainArray
.
setValueAt
(
1
,
3546
);
...
...
@@ -551,7 +551,7 @@ toString(): String
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
toString
();
...
...
@@ -577,7 +577,7 @@ clear(): void
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
plainArray
.
clear
();
...
...
@@ -617,10 +617,10 @@ callbackfn的参数说明:
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
plainArray
.
forEach
((
value
,
index
)
=>
{
plainArray
.
forEach
((
value
:
string
,
index
:
number
)
=>
{
console
.
log
(
"
value:
"
+
value
,
"
index:
"
+
index
);
});
```
...
...
@@ -651,22 +651,15 @@ plainArray.forEach((value, index) => {
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
let
plainArray
:
PlainArray
<
string
>
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
// 使用方法一:
for
(
let
item
of
plainArray
)
{
console
.
log
(
"
key:
"
+
item
[
0
]);
console
.
log
(
"
value:
"
+
item
[
1
]);
}
// 使用方法二:
let
iter
=
plainArray
[
Symbol
.
iterator
]();
let
temp
=
iter
.
next
()
.
value
;
while
(
temp
!=
undefined
)
{
console
.
log
(
"
key:
"
+
temp
[
0
]);
console
.
log
(
"
value:
"
+
temp
[
1
]);
temp
=
iter
.
next
()
.
value
;
let
temp
=
iter
.
next
();
while
(
!
temp
.
done
)
{
console
.
log
(
"
key:
"
+
temp
.
value
[
0
]);
console
.
log
(
"
value:
"
+
temp
.
value
[
1
]);
temp
=
iter
.
next
();
}
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录