Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
db4817c2
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看板
提交
db4817c2
编写于
2年前
作者:
L
liu-ganlin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add containers exception information
Signed-off-by:
N
liu-ganlin
<
liuganlin@huawei.com
>
上级
370c8642
master
OpenHarmony-3.2-Beta5
OpenHarmony-3.2-Release
OpenHarmony-4.0-Beta1
OpenHarmony-4.0-Beta2
bak_OpenHarmony-4.0-Beta1_20230529
docs-modify
monthly_20230815
revert-merge-17651-master
revert-merge-19334-OpenHarmony-4.0-Beta1
revert-merge-19586-master
revert-merge-20613-master
revert-merge-21757-OpenHarmony-4.0-Beta2
revert-merge-21765-OpenHarmony-4.0-Beta2
revert-merge-23766-master
weekly_20221101
weekly_20221108
weekly_20221115
weekly_20221122
weekly_20221129
weekly_20221206
weekly_20221213
weekly_20221220
weekly_20221227
weekly_20230103
weekly_20230110
weekly_20230117
weekly_20230124
weekly_20230131
weekly_20230207
weekly_20230214
weekly_20230221
weekly_20230228
weekly_20230307
weekly_20230314
weekly_20230321
weekly_20230328
weekly_20230404
weekly_20230411
weekly_20230418
weekly_20230425
weekly_20230502
weekly_20230509
weekly_20230516
weekly_20230523
weekly_20230530
weekly_20230606
weekly_20230613
weekly_20230619
weekly_20230626
weekly_20230627
weekly_20230704
weekly_20230712
weekly_20230725
weekly_20230801
weekly_20230808
weekly_20230815
weekly_20230822
weekly_20230829
weekly_20230905
OpenHarmony-v4.0-Beta2
OpenHarmony-v4.0-Beta1
OpenHarmony-v3.2.3-Release
OpenHarmony-v3.2.2-Release
OpenHarmony-v3.2.1-Release
OpenHarmony-v3.2-Release
OpenHarmony-v3.2-Beta5
无相关合并请求
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
2847 addition
and
18 deletion
+2847
-18
zh-cn/application-dev/reference/apis/js-apis-arraylist.md
zh-cn/application-dev/reference/apis/js-apis-arraylist.md
+311
-0
zh-cn/application-dev/reference/apis/js-apis-deque.md
zh-cn/application-dev/reference/apis/js-apis-deque.md
+132
-0
zh-cn/application-dev/reference/apis/js-apis-hashmap.md
zh-cn/application-dev/reference/apis/js-apis-hashmap.md
+197
-0
zh-cn/application-dev/reference/apis/js-apis-hashset.md
zh-cn/application-dev/reference/apis/js-apis-hashset.md
+133
-1
zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md
.../application-dev/reference/apis/js-apis-lightweightmap.md
+327
-7
zh-cn/application-dev/reference/apis/js-apis-lightweightset.md
.../application-dev/reference/apis/js-apis-lightweightset.md
+255
-0
zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
+330
-0
zh-cn/application-dev/reference/apis/js-apis-list.md
zh-cn/application-dev/reference/apis/js-apis-list.md
+300
-1
zh-cn/application-dev/reference/apis/js-apis-plainarray.md
zh-cn/application-dev/reference/apis/js-apis-plainarray.md
+260
-6
zh-cn/application-dev/reference/apis/js-apis-queue.md
zh-cn/application-dev/reference/apis/js-apis-queue.md
+80
-1
zh-cn/application-dev/reference/apis/js-apis-stack.md
zh-cn/application-dev/reference/apis/js-apis-stack.md
+106
-0
zh-cn/application-dev/reference/apis/js-apis-treemap.md
zh-cn/application-dev/reference/apis/js-apis-treemap.md
+250
-1
zh-cn/application-dev/reference/apis/js-apis-treeset.md
zh-cn/application-dev/reference/apis/js-apis-treeset.md
+91
-1
zh-cn/application-dev/reference/errorcodes/errorcode-containers.md
...lication-dev/reference/errorcodes/errorcode-containers.md
+75
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-arraylist.md
浏览文件 @
db4817c2
...
...
@@ -39,10 +39,23 @@ ArrayList的构造函数。
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200012 | The ArrayList's constructor cannot be directly invoked. |
**示例:**
```
ts
let
arrayList
=
new
ArrayList
();
try
{
let
arrayList2
=
ArrayList
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -66,6 +79,14 @@ add(element: T): boolean
| -------- | -------- |
| boolean | 插入成功返回true,失败返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The add method cannot be bound. |
**示例:**
```
ts
...
...
@@ -76,6 +97,11 @@ add(element: T): boolean
let
result2
=
arrayList
.
add
(
b
);
let
c
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
let
result3
=
arrayList
.
add
(
false
);
try
{
arraylist
.
add
.
bind
({},
"
b
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### insert
...
...
@@ -93,6 +119,15 @@ insert(element: T, index: number): void
| element | T | 是 | 被插入的元素。 |
| index | number | 是 | 被插入的位置索引。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The insert method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -100,6 +135,21 @@ let arrayList = new ArrayList();
arrayList
.
insert
(
"
A
"
,
0
);
arrayList
.
insert
(
0
,
1
);
arrayList
.
insert
(
true
,
2
);
try
{
arraylist
.
insert
.
bind
({},
1
,
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
let
res
=
arrayList
.
insert
(
8
,
11
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
let
res
=
arrayList
.
insert
(
"
a
"
,
"
b
"
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### has
...
...
@@ -122,6 +172,14 @@ has(element: T): boolean
| -------- | -------- |
| boolean | 返回true表示包含指定元素,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The has method cannot be bound. |
**示例:**
```
ts
...
...
@@ -129,6 +187,11 @@ let arrayList = new ArrayList();
let
result
=
arrayList
.
has
(
"
squirrel
"
);
arrayList
.
add
(
"
squirrel
"
);
let
result1
=
arrayList
.
has
(
"
squirrel
"
);
try
{
arraylist
.
has
.
bind
({},
"
squirrel
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getIndexOf
...
...
@@ -151,6 +214,14 @@ getIndexOf(element: T): number
| -------- | -------- |
| number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getIndexOf method cannot be bound. |
**示例:**
```
ts
...
...
@@ -163,6 +234,11 @@ arrayList.add(1);
arrayList
.
add
(
2
);
arrayList
.
add
(
4
);
let
result
=
arrayList
.
getIndexOf
(
2
);
try
{
arraylist
.
getIndexOf
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getLastIndexOf
...
...
@@ -185,6 +261,14 @@ getLastIndexOf(element: T): number
| -------- | -------- |
| number | 返回指定元素最后一次出现时的下标值,查找失败返回-1。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getLastIndexOf method cannot be bound. |
**示例:**
```
ts
...
...
@@ -197,6 +281,11 @@ arrayList.add(1);
arrayList
.
add
(
2
);
arrayList
.
add
(
4
);
let
result
=
arrayList
.
getLastIndexOf
(
2
);
try
{
arraylist
.
getLastIndexOf
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### removeByIndex
...
...
@@ -219,6 +308,15 @@ removeByIndex(index: number): T
| -------- | -------- |
| T | 返回删除的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The removeByIndex method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -229,6 +327,21 @@ arrayList.add(5);
arrayList
.
add
(
2
);
arrayList
.
add
(
4
);
let
result
=
arrayList
.
removeByIndex
(
2
);
try
{
arraylist
.
removeByIndex
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
arraylist
.
removeByIndex
(
"
a
"
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
arraylist
.
removeByIndex
(
8
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### remove
...
...
@@ -251,6 +364,14 @@ remove(element: T): boolean
| -------- | -------- |
| boolean | 删除成功返回true,失败返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The remove method cannot be bound. |
**示例:**
```
ts
...
...
@@ -260,6 +381,11 @@ arrayList.add(4);
arrayList
.
add
(
5
);
arrayList
.
add
(
4
);
let
result
=
arrayList
.
remove
(
2
);
try
{
arraylist
.
remove
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### removeByRange
...
...
@@ -277,6 +403,15 @@ removeByRange(fromIndex: number, toIndex: number): void
| fromIndex | number | 是 | 起始下标。 |
| toIndex | number | 是 | 终止下标。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The removeByRange method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -288,6 +423,16 @@ arrayList.add(4);
arrayList
.
removeByRange
(
2
,
4
);
arrayList
.
removeByRange
(
4
,
3
);
arrayList
.
removeByRange
(
2
,
6
);
try
{
arraylist
.
removeByRange
.
bind
({},
2
,
4
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
arraylist
.
removeByRange
(
8
,
4
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### replaceAllElements
...
...
@@ -314,6 +459,14 @@ callbackfn的参数说明:
| index | number | 否 | 当前遍历到的下标值。 |
| arrlist | ArrayList
<
T
>
| 否 | 当前调用replaceAllElements方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The replaceAllElements method cannot be bound. |
**示例:**
```
ts
...
...
@@ -328,6 +481,13 @@ arrayList.replaceAllElements((value: number, index: number)=> {
arrayList
.
replaceAllElements
((
value
:
number
,
index
:
number
)
=>
{
return
value
=
value
-
2
;
});
try
{
arraylist
.
replaceAllElements
.
bind
({},
(
value
:
number
,
index
:
number
)
=>
{
return
value
=
2
*
value
;
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### forEach
...
...
@@ -354,6 +514,14 @@ callbackfn的参数说明:
| index | number | 否 | 当前遍历到的下标值。 |
| arrlist | ArrayList
<
T
>
| 否 | 当前调用forEach方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The forEach method cannot be bound. |
**示例:**
```
ts
...
...
@@ -365,6 +533,13 @@ arrayList.add(4);
arrayList
.
forEach
((
value
,
index
)
=>
{
console
.
log
(
`value:
${
value
}
`
,
index
);
});
try
{
arraylist
.
forEach
.
bind
({},
(
value
,
index
)
=>
{
console
.
log
(
`value:
${
value
}
`
,
index
);
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### sort
...
...
@@ -388,6 +563,14 @@ comparator的参数说明:
| firstValue | T | 是 | 前一项元素。 |
| secondValue | T | 是 | 后一项元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The sort method cannot be bound. |
**示例:**
```
ts
...
...
@@ -399,6 +582,11 @@ arrayList.add(4);
arrayList
.
sort
((
a
:
number
,
b
:
number
)
=>
a
-
b
);
arrayList
.
sort
((
a
:
number
,
b
:
number
)
=>
b
-
a
);
arrayList
.
sort
();
try
{
arraylist
.
sort
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### subArrayList
...
...
@@ -422,6 +610,15 @@ subArrayList(fromIndex: number, toIndex: number): ArrayList<T>
| -------- | -------- |
| ArrayList
<
T
>
| 返回ArrayList对象实例。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The subArrayList method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -433,6 +630,16 @@ arrayList.add(4);
let
result1
=
arrayList
.
subArrayList
(
2
,
4
);
let
result2
=
arrayList
.
subArrayList
(
4
,
3
);
let
result3
=
arrayList
.
subArrayList
(
2
,
6
);
try
{
arraylist
.
subArrayList
.
bind
({},
2
,
4
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
arraylist
.
subArrayList
(
6
,
4
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### clear
...
...
@@ -443,6 +650,14 @@ clear(): void
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The clear method cannot be bound. |
**示例:**
```
ts
...
...
@@ -452,6 +667,11 @@ arrayList.add(4);
arrayList
.
add
(
5
);
arrayList
.
add
(
4
);
arrayList
.
clear
();
try
{
arraylist
.
clear
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### clone
...
...
@@ -469,6 +689,14 @@ clone(): ArrayList<T>
| -------- | -------- |
| ArrayList
<
T
>
| 返回ArrayList对象实例。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The clone method cannot be bound. |
**示例:**
```
ts
...
...
@@ -478,6 +706,11 @@ arrayList.add(4);
arrayList
.
add
(
5
);
arrayList
.
add
(
4
);
let
result
=
arrayList
.
clone
();
try
{
arraylist
.
clone
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getCapacity
...
...
@@ -494,6 +727,14 @@ getCapacity(): number
| -------- | -------- |
| number | 返回arraylist的容量大小。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getCapacity method cannot be bound. |
**示例:**
```
ts
...
...
@@ -503,6 +744,11 @@ arrayList.add(4);
arrayList
.
add
(
5
);
arrayList
.
add
(
4
);
let
result
=
arrayList
.
getCapacity
();
try
{
arraylist
.
getCapacity
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### convertToArray
...
...
@@ -519,6 +765,14 @@ convertToArray(): Array<T>
| -------- | -------- |
| Array
<
T
>
| 返回数组类型。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The convertToArray method cannot be bound. |
**示例:**
```
ts
...
...
@@ -528,6 +782,11 @@ arrayList.add(4);
arrayList
.
add
(
5
);
arrayList
.
add
(
4
);
let
result
=
arrayList
.
convertToArray
();
try
{
arraylist
.
convertToArray
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### isEmpty
...
...
@@ -544,6 +803,14 @@ isEmpty(): boolean
| -------- | -------- |
| boolean | 为空返回true,不为空返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The isEmpty method cannot be bound. |
**示例:**
```
ts
...
...
@@ -553,6 +820,11 @@ arrayList.add(4);
arrayList
.
add
(
5
);
arrayList
.
add
(
4
);
let
result
=
arrayList
.
isEmpty
();
try
{
arraylist
.
isEmpty
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### increaseCapacityTo
...
...
@@ -569,6 +841,14 @@ increaseCapacityTo(newCapacity: number): void
| -------- | -------- | -------- | -------- |
| newCapacity | number | 是 | 新容量。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The increaseCapacityTo method cannot be bound. |
**示例:**
```
ts
...
...
@@ -579,6 +859,11 @@ arrayList.add(5);
arrayList
.
add
(
4
);
arrayList
.
increaseCapacityTo
(
2
);
arrayList
.
increaseCapacityTo
(
8
);
try
{
arraylist
.
increaseCapacityTo
.
bind
({},
5
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### trimToCurrentLength
...
...
@@ -589,6 +874,14 @@ trimToCurrentLength(): void
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The trimToCurrentLength method cannot be bound. |
**示例:**
```
ts
...
...
@@ -598,6 +891,11 @@ arrayList.add(4);
arrayList
.
add
(
5
);
arrayList
.
add
(
4
);
arrayList
.
trimToCurrentLength
();
try
{
arraylist
.
trimToCurrentLength
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### [Symbol.iterator]
...
...
@@ -614,6 +912,14 @@ arrayList.trimToCurrentLength();
| -------- | -------- |
| IterableIterator
<
T
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
**示例:**
```
ts
...
...
@@ -635,4 +941,9 @@ while(temp != undefined) {
console
.
log
(
`value:
${
temp
}
`
);
temp
=
iter
.
next
().
value
;
}
try
{
arraylist
[
Symbol
.
iterator
].
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zh-cn/application-dev/reference/apis/js-apis-deque.md
浏览文件 @
db4817c2
...
...
@@ -38,10 +38,23 @@ Deque的构造函数。
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200012 | The Deque's constructor cannot be directly invoked. |
**示例:**
```
ts
let
deque
=
new
Deque
();
try
{
let
deque2
=
Deque
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### insertFront
...
...
@@ -58,6 +71,14 @@ insertFront(element: T): void
| -------- | -------- | -------- | -------- |
| element | T | 是 | 插入的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The insertFront method cannot be bound. |
**示例:**
```
ts
...
...
@@ -68,6 +89,11 @@ let b = [1, 2, 3];
deque
.
insertFront
(
b
);
let
c
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
deque
.
insertFront
(
false
);
try
{
deque
.
insertFront
.
bind
({},
"
b
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### insertEnd
...
...
@@ -84,6 +110,14 @@ insertEnd(element: T): void
| -------- | -------- | -------- | -------- |
| element | T | 是 | 插入的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The insertEnd method cannot be bound. |
**示例:**
```
ts
...
...
@@ -94,6 +128,11 @@ let b = [1, 2, 3];
deque
.
insertEnd
(
b
);
let
c
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
deque
.
insertEnd
(
false
);
try
{
deque
.
insertEnd
.
bind
({},
"
b
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### has
...
...
@@ -116,6 +155,14 @@ has(element: T): boolean
| -------- | -------- |
| boolean | 如果包含指定元素返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The has method cannot be bound. |
**示例:**
```
ts
...
...
@@ -123,6 +170,11 @@ let deque = new Deque();
let
result
=
deque
.
has
(
"
squirrel
"
);
deque
.
insertFront
(
"
squirrel
"
);
let
result1
=
deque
.
has
(
"
squirrel
"
);
try
{
deque
.
has
.
bind
({},
"
b
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### popFirst
...
...
@@ -139,6 +191,14 @@ popFirst(): T
| -------- | -------- |
| T | 返回被删除的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The popFirst method cannot be bound. |
**示例:**
```
ts
...
...
@@ -149,6 +209,11 @@ deque.insertEnd(5);
deque
.
insertFront
(
2
);
deque
.
insertFront
(
4
);
let
result
=
deque
.
popFirst
();
try
{
deque
.
popFirst
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### popLast
...
...
@@ -165,6 +230,14 @@ popLast(): T
| -------- | -------- |
| T | 返回被删除的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The popLast method cannot be bound. |
**示例:**
```
ts
...
...
@@ -175,6 +248,11 @@ deque.insertFront(5);
deque
.
insertFront
(
2
);
deque
.
insertFront
(
4
);
let
result
=
deque
.
popLast
();
try
{
deque
.
popLast
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### forEach
...
...
@@ -201,6 +279,14 @@ callbackfn的参数说明:
| index | number | 否 | 当前遍历到的下标值。 |
| deque | Deque
<
T
>
| 否 | 当前调用forEach方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The forEach method cannot be bound. |
**示例:**
```
ts
...
...
@@ -212,6 +298,13 @@ deque.insertEnd(4);
deque
.
forEach
((
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
index
);
});
try
{
deque
.
forEach
.
bind
({},
(
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
index
);
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getFirst
...
...
@@ -228,6 +321,14 @@ getFirst(): T
| -------- | -------- |
| T | 返回T型 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getFirst method cannot be bound. |
**示例:**
```
ts
...
...
@@ -237,6 +338,11 @@ deque.insertEnd(4);
deque
.
insertFront
(
5
);
deque
.
insertFront
(
4
);
let
result
=
deque
.
getFirst
();
try
{
deque
.
getFirst
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getLast
...
...
@@ -253,6 +359,14 @@ getLast(): T
| -------- | -------- |
| T | 返回T型 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getLast method cannot be bound. |
**示例:**
```
ts
...
...
@@ -262,6 +376,11 @@ deque.insertFront(4);
deque
.
insertFront
(
5
);
deque
.
insertFront
(
4
);
let
result
=
deque
.
getLast
();
try
{
deque
.
getLast
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### [Symbol.iterator]
...
...
@@ -278,6 +397,14 @@ let result = deque.getLast();
| -------- | -------- |
| IterableIterator
<
T
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
**示例:**
```
ts
let
deque
=
new
Deque
();
...
...
@@ -298,4 +425,9 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
try
{
deque
[
Symbol
.
iterator
].
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zh-cn/application-dev/reference/apis/js-apis-hashmap.md
浏览文件 @
db4817c2
...
...
@@ -40,10 +40,23 @@ HashMap的构造函数。
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200012 | The HashMap's constructor cannot be directly invoked. |
**示例:**
```
ts
let
hashMap
=
new
HashMap
();
try
{
let
hashMap2
=
HashMap
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -61,11 +74,24 @@ isEmpty(): boolean
| -------- | -------- |
| boolean | 为空返回true,不为空返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The isEmpty method cannot be bound. |
**示例:**
```
ts
const
hashMap
=
new
HashMap
();
let
result
=
hashMap
.
isEmpty
();
try
{
hashMap
.
isEmpty
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -89,6 +115,14 @@ hasKey(key: K): boolean
| -------- | -------- |
| boolean | 包含指定Key返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The hasKey method cannot be bound. |
**示例:**
```
ts
...
...
@@ -96,6 +130,11 @@ let hashMap = new HashMap();
let
result
=
hashMap
.
hasKey
(
"
squirrel
"
);
hashMap
.
set
(
"
squirrel
"
,
123
);
let
result1
=
hashMap
.
hasKey
(
"
squirrel
"
);
try
{
hashMap
.
hasKey
.
bind
({},
"
squirrel
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -119,6 +158,14 @@ hasValue(value: V): boolean
| -------- | -------- |
| boolean | 包含指定value返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The hasValue method cannot be bound. |
**示例:**
```
ts
...
...
@@ -126,6 +173,11 @@ let hashMap = new HashMap();
let
result
=
hashMap
.
hasValue
(
123
);
hashMap
.
set
(
"
squirrel
"
,
123
);
let
result1
=
hashMap
.
hasValue
(
123
);
try
{
hashMap
.
hasValue
.
bind
({},
123
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -149,6 +201,14 @@ get(key: K): V
| -------- | -------- |
| V | 返回key映射的value值。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The get method cannot be bound. |
**示例:**
```
ts
...
...
@@ -156,6 +216,11 @@ let hashMap = new HashMap();
hashMap
.
set
(
"
squirrel
"
,
123
);
hashMap
.
set
(
"
sparrow
"
,
356
);
let
result
=
hashMap
.
get
(
"
sparrow
"
);
try
{
hashMap
.
get
.
bind
({},
"
sparrow
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -173,6 +238,14 @@ setAll(map: HashMap<K, V>): void
| -------- | -------- | -------- | -------- |
| map | HashMap
<K
,
V
>
| 是 | 被添加元素的hashMap。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The setAll method cannot be bound. |
**示例:**
```
ts
...
...
@@ -181,6 +254,11 @@ hashMap.set("squirrel", 123);
hashMap
.
set
(
"
sparrow
"
,
356
);
let
newHashMap
=
new
HashMap
();
hashMap
.
setAll
(
newHashMap
);
try
{
hashMap
.
setAll
.
bind
({},
newHashMap
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -205,11 +283,24 @@ set(key: K, value: V): Object
| -------- | -------- |
| Object | 返回添加后的hashMap。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The set method cannot be bound. |
**示例:**
```
ts
let
hashMap
=
new
HashMap
();
let
result
=
hashMap
.
set
(
"
squirrel
"
,
123
);
try
{
hashMap
.
set
.
bind
({},
"
squirrel
"
,
123
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -233,6 +324,14 @@ remove(key: K): V
| -------- | -------- |
| V | 返回删除元素的值。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The remove method cannot be bound. |
**示例:**
```
ts
...
...
@@ -240,6 +339,11 @@ let hashMap = new HashMap();
hashMap
.
set
(
"
squirrel
"
,
123
);
hashMap
.
set
(
"
sparrow
"
,
356
);
let
result
=
hashMap
.
remove
(
"
sparrow
"
);
try
{
hashMap
.
remove
.
bind
({},
"
sparrow
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -251,6 +355,14 @@ clear(): void
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The clear method cannot be bound. |
**示例:**
```
ts
...
...
@@ -258,6 +370,11 @@ let hashMap = new HashMap();
hashMap
.
set
(
"
squirrel
"
,
123
);
hashMap
.
set
(
"
sparrow
"
,
356
);
hashMap
.
clear
();
try
{
hashMap
.
clear
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -275,6 +392,14 @@ keys(): IterableIterator<K>
| -------- | -------- |
| IterableIterator
<
K
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The keys method cannot be bound. |
**示例:**
```
ts
...
...
@@ -287,6 +412,11 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
try
{
hashMap
.
keys
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -304,6 +434,14 @@ values(): IterableIterator<V>
| -------- | -------- |
| IterableIterator
<
V
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The values method cannot be bound. |
**示例:**
```
ts
...
...
@@ -316,6 +454,11 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
try
{
hashMap
.
values
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -340,12 +483,25 @@ replace(key: K, newValue: V): boolean
| -------- | -------- |
| boolean | 是否成功对已有数据进行替换 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The replace method cannot be bound. |
**示例:**
```
ts
let
hashMap
=
new
HashMap
();
hashMap
.
set
(
"
sparrow
"
,
123
);
let
result
=
hashMap
.
replace
(
"
sparrow
"
,
357
);
try
{
hashMap
.
replace
.
bind
({},
"
sparrow
"
,
357
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -371,6 +527,14 @@ callbackfn的参数说明:
| key | K | 否 | 当前遍历到的元素键值对的键。 |
| map | HashMap
<K
,
V
>
| 否 | 当前调用forEach方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The forEach method cannot be bound. |
**示例:**
```
ts
...
...
@@ -380,6 +544,13 @@ hashMap.set("gull", 357);
hashMap
.
forEach
((
value
,
key
)
=>
{
console
.
log
(
"
value:
"
+
value
,
key
);
});
try
{
hashMap
.
forEach
.
bind
({},
(
value
,
key
)
=>
{
console
.
log
(
"
value:
"
+
value
,
key
);
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -397,6 +568,14 @@ entries(): IterableIterator<[K, V]>
| -------- | -------- |
| IterableIterator
<
[K, V]
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The entries method cannot be bound. |
**示例:**
```
ts
...
...
@@ -410,6 +589,11 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
[
1
]);
temp
=
iter
.
next
().
value
;
}
try
{
hashMap
.
entries
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -427,6 +611,14 @@ while(temp != undefined) {
| -------- | -------- |
| IterableIterator
<
[K, V]
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
**示例:**
```
ts
let
hashMap
=
new
HashMap
();
...
...
@@ -447,4 +639,9 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
[
1
]);
temp
=
iter
.
next
().
value
;
}
try
{
hashMap
[
Symbol
.
iterator
].
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zh-cn/application-dev/reference/apis/js-apis-hashset.md
浏览文件 @
db4817c2
...
...
@@ -48,10 +48,23 @@ HashSet的构造函数。
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200012 | The HashSet's constructor cannot be directly invoked. |
**示例:**
```
ts
let
hashSet
=
new
HashSet
();
try
{
let
hashSet2
=
HashSet
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -69,11 +82,24 @@ isEmpty(): boolean
| -------- | -------- |
| boolean | 为空返回true,不为空返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The isEmpty method cannot be bound. |
**示例:**
```
ts
const
hashSet
=
new
HashSet
();
let
result
=
hashSet
.
isEmpty
();
try
{
hashSet
.
isEmpty
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -97,6 +123,14 @@ has(value: T): boolean
| -------- | -------- |
| boolean | 包含指定元素返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The has method cannot be bound. |
**示例:**
```
ts
...
...
@@ -104,6 +138,11 @@ let hashSet = new HashSet();
let
result
=
hashSet
.
has
(
"
squirrel
"
);
hashSet
.
add
(
"
squirrel
"
);
let
result1
=
hashSet
.
has
(
"
squirrel
"
);
try
{
hashSet
.
has
.
bind
({},
"
squirrel
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -127,11 +166,24 @@ add(value: T): boolean
| -------- | -------- |
| boolean | 成功增加元素返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The add method cannot be bound. |
**示例:**
```
ts
let
hashSet
=
new
HashSet
();
let
result
=
hashSet
.
add
(
"
squirrel
"
);
try
{
hashSet
.
add
.
bind
({},
"
squirrel
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -155,6 +207,14 @@ remove(value: T): boolean
| -------- | -------- |
| boolean | 成功删除指定元素返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The remove method cannot be bound. |
**示例:**
```
ts
...
...
@@ -162,6 +222,11 @@ let hashSet = new HashSet();
hashSet
.
add
(
"
squirrel
"
);
hashSet
.
add
(
"
sparrow
"
);
let
result
=
hashSet
.
remove
(
"
sparrow
"
);
try
{
hashSet
.
remove
.
bind
({},
"
sparrow
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -173,6 +238,14 @@ clear(): void
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The clear method cannot be bound. |
**示例:**
```
ts
...
...
@@ -180,6 +253,11 @@ let hashSet = new HashSet();
hashSet
.
add
(
"
squirrel
"
);
hashSet
.
add
(
"
sparrow
"
);
hashSet
.
clear
();
try
{
hashSet
.
remove
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -197,6 +275,14 @@ values(): IterableIterator<T>
| -------- | -------- |
| IterableIterator
<
T
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The values method cannot be bound. |
**示例:**
```
ts
...
...
@@ -208,7 +294,12 @@ let temp = iter.next().value;
while
(
temp
!=
undefined
)
{
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
}
try
{
hashSet
.
values
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -234,6 +325,14 @@ callbackfn的参数说明:
| key | T | 否 | 当前遍历到的元素键值对的值(和value相同)。 |
| set | HashSet
<
T
>
| 否 | 当前调用forEach方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The forEach method cannot be bound. |
**示例:**
```
ts
...
...
@@ -243,6 +342,13 @@ hashSet.add("squirrel");
hashSet
.
forEach
((
value
,
key
)
=>
{
console
.
log
(
"
value:
"
+
value
,
key
);
});
try
{
hashSet
.
forEach
.
bind
({},
(
value
,
key
)
=>
{
console
.
log
(
"
value:
"
+
value
,
key
);
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -259,6 +365,14 @@ entries(): IterableIterator<[T, T]>
| -------- | -------- |
| IterableIterator
<
[
T
,
T
]
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The entries method cannot be bound. |
**示例:**
```
ts
...
...
@@ -272,6 +386,11 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
[
1
]);
temp
=
iter
.
next
().
value
;
}
try
{
hashSet
.
entries
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -289,6 +408,14 @@ while(temp != undefined) {
| -------- | -------- |
| IterableIterator
<
T
>
| 返回一个迭代器 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
**示例:**
```
ts
...
...
@@ -308,4 +435,9 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
try
{
hashSet
[
Symbol
.
iterator
].
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md
浏览文件 @
db4817c2
...
...
@@ -42,10 +42,24 @@ LightWeightMap的构造函数。
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200012 | The LightWeightMap's constructor cannot be directly invoked. |
**示例:**
```
ts
let
lightWeightMap
=
new
LightWeightMap
();
try
{
let
lightWeightMap2
=
LightWeightMap
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -63,11 +77,24 @@ isEmpty(): boolean
| -------- | -------- |
| boolean | 为空返回true,不为空返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The isEmpty method cannot be bound. |
**示例:**
```
ts
const
lightWeightMap
=
new
LightWeightMap
();
let
result
=
lightWeightMap
.
isEmpty
();
try
{
lightWeightMap
.
isEmpty
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -91,6 +118,14 @@ hasAll(map: LightWeightMap<K, V>): boolean
| -------- | -------- |
| boolean | 包含所有元素返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The hasAll method cannot be bound. |
**示例:**
```
ts
...
...
@@ -100,6 +135,11 @@ lightWeightMap.set("sparrow", 356);
let
map
=
new
LightWeightMap
();
map
.
set
(
"
sparrow
"
,
356
);
let
result
=
lightWeightMap
.
hasAll
(
map
);
try
{
lightWeightMap
.
hasAll
.
bind
({},
map
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -123,6 +163,14 @@ hasKey(key: K): boolean;
| -------- | -------- |
| boolean | 包含指定key返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The hasKey method cannot be bound. |
**示例:**
```
ts
...
...
@@ -131,6 +179,11 @@ let result = lightWeightMap.hasKey;
lightWeightMap
.
hasKey
(
"
squirrel
"
);
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
let
result1
=
lightWeightMap
.
hasKey
(
"
squirrel
"
);
try
{
lightWeightMap
.
hasKey
.
bind
({},
"
squirrel
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -154,6 +207,14 @@ hasValue(value: V): boolean
| -------- | -------- |
| boolean | 包含指定元素返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The hasValue method cannot be bound. |
**示例:**
```
ts
...
...
@@ -161,6 +222,11 @@ let lightWeightMap = new LightWeightMap();
let
result
=
lightWeightMap
.
hasValue
(
123
);
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
let
result1
=
lightWeightMap
.
hasValue
(
123
);
try
{
lightWeightMap
.
hasValue
.
bind
({},
123
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -172,6 +238,14 @@ increaseCapacityTo(minimumCapacity: number): void
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The increaseCapacityTo method cannot be bound. |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -183,6 +257,11 @@ increaseCapacityTo(minimumCapacity: number): void
```
ts
let
lightWeightMap
=
new
LightWeightMap
();
lightWeightMap
.
increaseCapacityTo
(
10
);
try
{
lightWeightMap
.
increaseCapacityTo
.
bind
({},
10
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -206,6 +285,14 @@ get(key: K): V
| -------- | -------- |
| V | 返回key映射的value值。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The get method cannot be bound. |
**示例:**
```
ts
...
...
@@ -213,6 +300,11 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
lightWeightMap
.
set
(
"
sparrow
"
,
356
);
let
result
=
lightWeightMap
.
get
(
"
sparrow
"
);
try
{
lightWeightMap
.
get
.
bind
({},
"
sparrow
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -236,6 +328,14 @@ getIndexOfKey(key: K): number
| -------- | -------- |
| number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getIndexOfKey method cannot be bound. |
**示例:**
```
ts
...
...
@@ -243,6 +343,11 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
lightWeightMap
.
set
(
"
sparrow
"
,
356
);
let
result
=
lightWeightMap
.
getIndexOfKey
(
"
sparrow
"
);
try
{
lightWeightMap
.
getIndexOfKey
.
bind
({},
"
sparrow
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -266,6 +371,14 @@ getIndexOfValue(value: V): number
| -------- | -------- |
| number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getIndexOfValue method cannot be bound. |
**示例:**
```
ts
...
...
@@ -273,6 +386,11 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
lightWeightMap
.
set
(
"
sparrow
"
,
356
);
let
result
=
lightWeightMap
.
getIndexOfValue
(
123
);
try
{
lightWeightMap
.
getIndexOfValue
.
bind
({},
123
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -296,6 +414,15 @@ getKeyAt(index: number): K
| -------- | -------- |
| K | 返回该下标对应的元素键值对中key值。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getKeyAt method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -303,6 +430,16 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
lightWeightMap
.
set
(
"
sparrow
"
,
356
);
let
result
=
lightWeightMap
.
getKeyAt
(
1
);
try
{
lightWeightMap
.
getKeyAt
.
bind
({},
1
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
lightWeightMap
.
getKeyAt
(
6
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -320,6 +457,14 @@ setAll(map: LightWeightMap<K, V>): void
| -------- | -------- | -------- | -------- |
| map | LightWeightMap
<K
,
V
>
| 是 | 被添加元素的lightWeightMap。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The setAll method cannot be bound. |
**示例:**
```
ts
...
...
@@ -328,6 +473,11 @@ lightWeightMap.set("squirrel", 123);
lightWeightMap
.
set
(
"
sparrow
"
,
356
);
let
map
=
new
LightWeightMap
();
lightWeightMap
.
setAll
(
map
);
try
{
lightWeightMap
.
setAll
.
bind
({},
map
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -351,11 +501,24 @@ set(key: K, value: V): Object
| -------- | -------- |
| Object | 返回添加数据后的lightWeightMap。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The set method cannot be bound. |
**示例:**
```
ts
let
lightWeightMap
=
new
LightWeightMap
();
let
result
=
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
try
{
lightWeightMap
.
set
.
bind
({},
"
squirrel
"
,
123
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -379,6 +542,14 @@ remove(key: K): V
| -------- | -------- |
| V | 返回删除元素的值。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The remove method cannot be bound. |
**示例:**
```
ts
...
...
@@ -386,6 +557,11 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
lightWeightMap
.
set
(
"
sparrow
"
,
356
);
lightWeightMap
.
remove
(
"
sparrow
"
);
try
{
lightWeightMap
.
remove
.
bind
({},
"
sparrow
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -409,6 +585,14 @@ removeAt(index: number): boolean
| -------- | -------- |
| boolean | 成功删除元素返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The removeAt method cannot be bound. |
**示例:**
```
ts
...
...
@@ -416,6 +600,11 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
lightWeightMap
.
set
(
"
sparrow
"
,
356
);
let
result
=
lightWeightMap
.
removeAt
(
1
);
try
{
lightWeightMap
.
removeAt
.
bind
({},
1
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -440,6 +629,15 @@ setValueAt(index: number, newValue: V): boolean
| -------- | -------- |
| boolean | 成功替换指定位置数据返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The setValueAt method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -447,6 +645,16 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
lightWeightMap
.
set
(
"
sparrow
"
,
356
);
lightWeightMap
.
setValueAt
(
1
,
3546
);
try
{
lightWeightMap
.
setValueAt
.
bind
({},
1
,
3546
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
lightWeightMap
.
setValueAt
(
6
,
3546
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -470,6 +678,15 @@ getValueAt(index: number): V
| -------- | -------- |
| V | 返回指定下标对应键值对中的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getValueAt method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -477,6 +694,16 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
lightWeightMap
.
set
(
"
sparrow
"
,
356
);
let
result
=
lightWeightMap
.
getValueAt
(
1
);
try
{
lightWeightMap
.
getValueAt
.
bind
({},
1
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
lightWeightMap
.
getValueAt
(
6
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -488,6 +715,14 @@ clear(): void
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The clear method cannot be bound. |
**示例:**
```
ts
...
...
@@ -495,6 +730,11 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
lightWeightMap
.
set
(
"
sparrow
"
,
356
);
lightWeightMap
.
clear
();
try
{
lightWeightMap
.
clear
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -512,6 +752,14 @@ keys(): IterableIterator<K>
| -------- | -------- |
| IterableIterator
<
K
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The keys method cannot be bound. |
**示例:**
```
ts
...
...
@@ -524,6 +772,11 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
try
{
lightWeightMap
.
keys
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -541,6 +794,14 @@ values(): IterableIterator<V>
| -------- | -------- |
| IterableIterator
<
V
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The values method cannot be bound. |
**示例:**
```
ts
...
...
@@ -552,7 +813,12 @@ let temp = iter.next().value;
while
(
temp
!=
undefined
)
{
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
}
try
{
lightWeightMap
.
values
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -578,6 +844,14 @@ callbackfn的参数说明:
| key | K | 否 | 当前遍历到的元素键值对的键。 |
| map | LightWeightMap
<K
,
V
>
| 否 | 当前调用forEach方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The forEach method cannot be bound. |
**示例:**
```
ts
...
...
@@ -587,6 +861,13 @@ lightWeightMap.set("gull", 357);
lightWeightMap
.
forEach
((
value
,
key
)
=>
{
console
.
log
(
"
value:
"
+
value
,
key
);
});
try
{
lightWeightMap
.
forEach
.
bind
({},
(
value
,
key
)
=>
{
console
.
log
(
"
value:
"
+
value
,
key
);
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -604,6 +885,14 @@ entries(): IterableIterator<[K, V]>
| -------- | -------- |
| IterableIterator
<
[
K
,
V
]
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The entries method cannot be bound. |
**示例:**
```
ts
...
...
@@ -617,6 +906,11 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
[
1
]);
temp
=
iter
.
next
().
value
;
}
try
{
lightWeightMap
.
entries
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### toString
...
...
@@ -633,14 +927,27 @@ toString(): String
| -------- | -------- |
| String | 返回一个字符串。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The toString method cannot be bound. |
**示例:**
```
ts
let
lightWeightMap
=
new
LightWeightMap
();
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
lightWeightMap
.
set
(
"
sparrow
"
,
356
);
let
iter
=
lightWeightMap
.
toString
();
```
```
ts
let
lightWeightMap
=
new
LightWeightMap
();
lightWeightMap
.
set
(
"
squirrel
"
,
123
);
lightWeightMap
.
set
(
"
sparrow
"
,
356
);
let
iter
=
lightWeightMap
.
toString
();
try
{
lightWeightMap
.
toString
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### [Symbol.iterator]
...
...
@@ -656,6 +963,14 @@ toString(): String
| -------- | -------- |
| IterableIterator
<
[
K
,
V
]
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
**示例:**
```
ts
...
...
@@ -677,4 +992,9 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
[
1
]);
temp
=
iter
.
next
().
value
;
}
try
{
lightWeightMap
[
Symbol
.
iterator
].
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zh-cn/application-dev/reference/apis/js-apis-lightweightset.md
浏览文件 @
db4817c2
...
...
@@ -43,10 +43,23 @@ LightWeightSet的构造函数。
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200012 | The LightWeightSet's constructor cannot be directly invoked. |
**示例:**
```
ts
let
lightWeightSet
=
new
LightWeightSet
();
try
{
let
lightWeightSet2
=
LightWeightSet
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -64,11 +77,24 @@ isEmpty(): boolean
| -------- | -------- |
| boolean | 为空返回true,不为空返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The isEmpty method cannot be bound. |
**示例:**
```
ts
const
lightWeightSet
=
new
LightWeightSet
();
let
result
=
lightWeightSet
.
isEmpty
();
try
{
lightWeightSet
.
isEmpty
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### add
...
...
@@ -91,11 +117,24 @@ add(obj: T): boolean
| -------- | -------- |
| boolean | 成功添加元素返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The add method cannot be bound. |
**示例:**
```
ts
let
lightWeightSet
=
new
LightWeightSet
();
let
result
=
lightWeightSet
.
add
(
"
squirrel
"
);
try
{
lightWeightSet
.
add
.
bind
({},
"
squirrel
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -113,6 +152,14 @@ addAll(set: LightWeightSet<T>): boolean
| -------- | -------- | -------- | -------- |
| set | LightWeightSet
<
T
>
| 是 | 提供添加元素的lightWeightSet。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The addAll method cannot be bound. |
**示例:**
```
ts
...
...
@@ -122,6 +169,11 @@ lightWeightSet.add("sparrow");
let
set
=
new
LightWeightSet
();
set
.
add
(
"
gull
"
);
let
result
=
lightWeightSet
.
addAll
(
set
);
try
{
lightWeightSet
.
addAll
.
bind
({},
set
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -145,6 +197,14 @@ hasAll(set: LightWeightSet<T>): boolean
| -------- | -------- |
| boolean | 包含所有元素返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The hasAll method cannot be bound. |
**示例:**
```
ts
...
...
@@ -154,6 +214,11 @@ lightWeightSet.add("sparrow");
let
set
=
new
LightWeightSet
();
set
.
add
(
"
sparrow
"
);
let
result
=
lightWeightSet
.
hasAll
(
set
);
try
{
lightWeightSet
.
hasAll
.
bind
({},
set
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -177,6 +242,14 @@ has(key: T): boolean
| -------- | -------- |
| boolean | 包含指定key返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The has method cannot be bound. |
**示例:**
```
ts
...
...
@@ -184,6 +257,11 @@ let lightWeightSet = new LightWeightSet();
let
result
=
lightWeightSet
.
has
(
123
);
lightWeightSet
.
add
(
123
);
result
=
lightWeightSet
.
has
(
123
);
try
{
lightWeightSet
.
has
.
bind
({},
123
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -207,6 +285,14 @@ equal(obj: Object): boolean
| -------- | -------- |
| boolean | 构成类型相同返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The equal method cannot be bound. |
**示例:**
```
ts
...
...
@@ -215,6 +301,11 @@ lightWeightSet.add("squirrel");
lightWeightSet
.
add
(
"
sparrow
"
);
let
obj
=
[
"
squirrel
"
,
"
sparrow
"
];
let
result
=
lightWeightSet
.
equal
(
obj
);
try
{
lightWeightSet
.
equal
.
bind
({},
obj
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -232,11 +323,30 @@ increaseCapacityTo(minimumCapacity: number): void
| -------- | -------- | -------- | -------- |
| minimumCapacity | number | 是 | 需要容纳数量。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The increaseCapacityTo method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
let
lightWeightSet
=
new
LightWeightSet
();
lightWeightSet
.
increaseCapacityTo
(
10
);
try
{
lightWeightSet
.
increaseCapacityTo
.
bind
({},
10
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
lightWeightSet
.
increaseCapacityTo
(
2
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -260,6 +370,14 @@ getIndexOf(key: T): number
| -------- | -------- |
| number | 在lightWeightSet中指定数据的下标。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getIndexOf method cannot be bound. |
**示例:**
```
ts
...
...
@@ -267,6 +385,11 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet
.
add
(
"
squirrel
"
);
lightWeightSet
.
add
(
"
sparrow
"
);
let
result
=
lightWeightSet
.
getIndexOf
(
"
sparrow
"
);
try
{
lightWeightSet
.
getIndexOf
.
bind
({},
"
sparrow
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -290,6 +413,14 @@ remove(key: T): T
| -------- | -------- |
| T | 返回删除元素的值。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The remove method cannot be bound. |
**示例:**
```
ts
...
...
@@ -297,6 +428,11 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet
.
add
(
"
squirrel
"
);
lightWeightSet
.
add
(
"
sparrow
"
);
let
result
=
lightWeightSet
.
remove
(
"
sparrow
"
);
try
{
lightWeightSet
.
remove
.
bind
({},
"
sparrow
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -320,6 +456,14 @@ removeAt(index: number): boolean
| -------- | -------- |
| boolean | 确认是否成功删除元素 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The removeAt method cannot be bound. |
**示例:**
```
ts
...
...
@@ -327,6 +471,11 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet
.
add
(
"
squirrel
"
);
lightWeightSet
.
add
(
"
sparrow
"
);
let
result
=
lightWeightSet
.
removeAt
(
1
);
try
{
lightWeightSet
.
removeAt
.
bind
({},
1
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -350,6 +499,14 @@ getValueAt(index: number): T
| -------- | -------- |
| T | 返回指定下标对应的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getValueAt method cannot be bound. |
**参数:**
```
ts
...
...
@@ -357,6 +514,11 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet
.
add
(
"
squirrel
"
);
lightWeightSet
.
add
(
"
sparrow
"
);
let
result
=
lightWeightSet
.
getValueAt
(
1
);
try
{
lightWeightSet
.
getValueAt
.
bind
({},
1
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -368,6 +530,14 @@ clear(): void
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The clear method cannot be bound. |
**示例:**
```
ts
...
...
@@ -375,6 +545,11 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet
.
add
(
"
squirrel
"
);
lightWeightSet
.
add
(
"
sparrow
"
);
lightWeightSet
.
clear
();
try
{
lightWeightSet
.
clear
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -392,6 +567,14 @@ toString(): String
| -------- | -------- |
| String | 返回对应字符串。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The toString method cannot be bound. |
**示例:**
```
ts
...
...
@@ -399,6 +582,11 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet
.
add
(
"
squirrel
"
);
lightWeightSet
.
add
(
"
sparrow
"
);
let
result
=
lightWeightSet
.
toString
();
try
{
lightWeightSet
.
toString
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -416,6 +604,14 @@ toArray(): Array<T>
| -------- | -------- |
| Array
<
T
>
| 返回对应数组。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The toArray method cannot be bound. |
**示例:**
```
ts
...
...
@@ -423,6 +619,11 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet
.
add
(
"
squirrel
"
);
lightWeightSet
.
add
(
"
sparrow
"
);
let
result
=
lightWeightSet
.
toArray
();
try
{
lightWeightSet
.
toArray
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -440,6 +641,14 @@ values(): IterableIterator<T>
| -------- | -------- |
| IterableIterator
<
T
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The values method cannot be bound. |
**示例:**
```
ts
...
...
@@ -452,6 +661,11 @@ while(index < lightWeightSet.length) {
console
.
log
(
JSON
.
stringify
(
iter
.
next
().
value
));
index
++
;
}
try
{
lightWeightSet
.
values
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -477,6 +691,14 @@ callbackfn的参数说明:
| key | T | 否 | 当前遍历到的元素(和value相同)。 |
| set | LightWeightSet
<
T
>
| 否 | 当前调用forEach方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The forEach method cannot be bound. |
**示例:**
```
ts
...
...
@@ -486,6 +708,13 @@ lightWeightSet.add("gull");
lightWeightSet
.
forEach
((
value
,
key
)
=>
{
console
.
log
(
"
value:
"
+
value
,
key
);
});
try
{
lightWeightSet
.
forEach
.
bind
({},
(
value
,
key
)
=>
{
console
.
log
(
"
value:
"
+
value
,
key
);
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -503,6 +732,14 @@ entries(): IterableIterator<[T, T]>
| -------- | -------- |
| IterableIterator
<
[
T
,
T
]
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The entries method cannot be bound. |
**示例:**
```
ts
...
...
@@ -515,6 +752,11 @@ while(index < lightWeightSet.length) {
console
.
log
(
JSON
.
stringify
(
iter
.
next
().
value
));
index
++
;
}
try
{
lightWeightSet
.
entries
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -532,6 +774,14 @@ while(index < lightWeightSet.length) {
| -------- | -------- |
| IterableIterator
<
T
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
**示例:**
```
ts
...
...
@@ -551,4 +801,9 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
try
{
lightWeightSet
[
Symbol
.
iterator
].
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
浏览文件 @
db4817c2
...
...
@@ -42,11 +42,24 @@ LinkedList的构造函数。
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200012 | The LinkedList's constructor cannot be directly invoked. |
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
try
{
let
linkedList2
=
LinkedList
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -70,6 +83,14 @@ add(element: T): boolean
| -------- | -------- |
| boolean | 插入成功返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The add method cannot be bound. |
**示例:**
```
ts
...
...
@@ -80,6 +101,11 @@ let b = [1, 2, 3];
linkedList
.
add
(
b
);
let
c
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
let
result3
=
linkedList
.
add
(
false
);
try
{
linkedList
.
add
.
bind
({},
"
b
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### addFirst
...
...
@@ -96,6 +122,14 @@ addFirst(element: T): void
| -------- | -------- | -------- | -------- |
| element | T | 是 | 待插入的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The addFirst method cannot be bound. |
**示例:**
```
ts
...
...
@@ -106,6 +140,11 @@ let b = [1, 2, 3];
linkedList
.
addFirst
(
b
);
let
c
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
linkedList
.
addFirst
(
false
);
try
{
linkedList
.
addFirst
.
bind
({},
"
b
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### insert
...
...
@@ -123,6 +162,15 @@ insert(index: number, element: T): void
| element | T | 是 | 插入元素。 |
| index | number | 是 | 插入位置索引。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The insert method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -130,6 +178,16 @@ let linkedList = new LinkedList();
linkedList
.
insert
(
0
,
"
A
"
);
linkedList
.
insert
(
1
,
0
);
linkedList
.
insert
(
2
,
true
);
try
{
linkedList
.
insert
.
bind
({},
3
,
"
b
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
linkedList
.
insert
(
6
,
"
b
"
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### has
...
...
@@ -152,6 +210,14 @@ has(element: T): boolean
| -------- | -------- |
| boolean | 包含指定元素返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The has method cannot be bound. |
**示例:**
```
ts
...
...
@@ -159,6 +225,11 @@ let linkedList = new LinkedList();
let
result1
=
linkedList
.
has
(
"
squirrel
"
);
linkedList
.
add
(
"
squirrel
"
);
let
result
=
linkedList
.
has
(
"
squirrel
"
);
try
{
linkedList
.
has
.
bind
({},
"
squirrel
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### get
...
...
@@ -181,6 +252,14 @@ get(index: number): T
| -------- | -------- |
| T | 根据下标查找到的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The get method cannot be bound. |
**示例:**
```
ts
...
...
@@ -193,6 +272,11 @@ linkedList.add(1);
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
get
(
2
);
try
{
linkedList
.
get
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getLastIndexOf
...
...
@@ -215,6 +299,14 @@ getLastIndexOf(element: T): number
| -------- | -------- |
| number | 返回指定元素最后一次出现时的下标值,查找失败返回-1。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getLastIndexOf method cannot be bound. |
**示例:**
```
ts
...
...
@@ -227,6 +319,11 @@ linkedList.add(1);
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
getLastIndexOf
(
2
);
try
{
linkedList
.
getLastIndexOf
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getIndexOf
...
...
@@ -249,6 +346,14 @@ getIndexOf(element: T): number
| -------- | -------- |
| number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getIndexOf method cannot be bound. |
**示例:**
```
ts
...
...
@@ -261,6 +366,11 @@ linkedList.add(1);
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
getIndexOf
(
2
);
try
{
linkedList
.
getIndexOf
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### removeByIndex
...
...
@@ -283,6 +393,15 @@ removeByIndex(index: number): T
| -------- | -------- |
| T | 返回删除的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The removeByIndex method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -293,6 +412,16 @@ linkedList.add(5);
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
removeByIndex
(
2
);
try
{
linkedList
.
removeByIndex
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
linkedList
.
removeByIndex
(
8
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### removeFirst
...
...
@@ -309,16 +438,35 @@ removeFirst(): T
| -------- | -------- |
| T | 返回删除的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The removeFirst method cannot be bound. |
| 10200010 | Container is empty. |
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
try
{
linkedList
.
removeFirst
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
removeFirst
();
try
{
linkedList
.
removeFirst
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### removeLast
...
...
@@ -335,16 +483,35 @@ removeLast(): T
| -------- | -------- |
| T | 返回删除的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The removeLast method cannot be bound. |
| 10200010 | Container is empty. |
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
try
{
linkedList
.
removeLast
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
removeLast
();
try
{
linkedList
.
removeLast
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### remove
...
...
@@ -367,6 +534,14 @@ remove(element: T): boolean
| -------- | -------- |
| boolean | 删除成功返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The remove method cannot be bound. |
**示例:**
```
ts
...
...
@@ -376,6 +551,11 @@ linkedList.add(4);
linkedList
.
add
(
5
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
remove
(
2
);
try
{
linkedList
.
remove
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### removeFirstFound
...
...
@@ -398,15 +578,34 @@ removeFirstFound(element: T): boolean
| -------- | -------- |
| boolean | 删除成功返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The removeFirstFound method cannot be bound. |
| 10200010 | Container is empty. |
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
try
{
linkedList
.
removeFirstFound
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
removeFirstFound
(
4
);
try
{
linkedList
.
removeFirstFound
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### removeLastFound
...
...
@@ -429,15 +628,34 @@ removeLastFound(element: T): boolean
| -------- | -------- |
| boolean | 删除成功返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The removeLastFound method cannot be bound. |
| 10200010 | Container is empty. |
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
try
{
linkedList
.
removeLastFound
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
linkedList
.
add
(
2
);
linkedList
.
add
(
4
);
linkedList
.
add
(
5
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
removeLastFound
(
4
);
try
{
linkedList
.
removeLastFound
.
bind
({},
4
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### clone
...
...
@@ -454,6 +672,14 @@ clone(): LinkedList<T>
| -------- | -------- |
| LinkedList
<
T
>
| 返回LinkedList对象实例。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The clone method cannot be bound. |
**示例:**
```
ts
...
...
@@ -463,6 +689,11 @@ linkedList.add(4);
linkedList
.
add
(
5
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
clone
();
try
{
linkedList
.
clone
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### forEach
...
...
@@ -489,6 +720,14 @@ callbackfn的参数说明:
| index | number | 否 | 当前遍历到的下标值。 |
| LinkedList | LinkedList
<
T
>
| 否 | 当前调用forEach方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The forEach method cannot be bound. |
**示例:**
```
ts
...
...
@@ -500,6 +739,13 @@ linkedList.add(4);
linkedList
.
forEach
((
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
index
);
});
try
{
linkedList
.
forEach
.
bind
({},
(
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
index
);
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### clear
...
...
@@ -510,6 +756,14 @@ clear(): void
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The clear method cannot be bound. |
**示例:**
```
ts
...
...
@@ -519,6 +773,11 @@ linkedList.add(4);
linkedList
.
add
(
5
);
linkedList
.
add
(
4
);
linkedList
.
clear
();
try
{
linkedList
.
clear
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### set
...
...
@@ -542,6 +801,15 @@ set(index: number, element: T): T
| -------- | -------- |
| T | 返回替换后的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The set method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -551,6 +819,16 @@ linkedList.add(4);
linkedList
.
add
(
5
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
set
(
2
,
"
b
"
);
try
{
linkedList
.
set
.
bind
({},
2
,
"
b
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
linkedList
.
set
(
8
,
"
b
"
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### convertToArray
...
...
@@ -567,6 +845,14 @@ convertToArray(): Array<T>
| -------- | -------- |
| Array
<
T
>
| 返回转换后的数组。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The convertToArray method cannot be bound. |
**示例:**
```
ts
let
linkedList
=
new
LinkedList
();
...
...
@@ -575,6 +861,11 @@ linkedList.add(4);
linkedList
.
add
(
5
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
convertToArray
();
try
{
linkedList
.
convertToArray
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getFirst
...
...
@@ -591,6 +882,14 @@ getFirst(): T
| -------- | -------- |
| T | 返回对应元素,如果为空返回undefined。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getFirst method cannot be bound. |
**示例:**
```
ts
...
...
@@ -600,6 +899,11 @@ linkedList.add(4);
linkedList
.
add
(
5
);
linkedList
.
add
(
4
);
let
result
=
linkedList
.
getFirst
();
try
{
linkedList
.
getFirst
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getLast
...
...
@@ -616,6 +920,14 @@ getLast(): T
| -------- | -------- |
| T | 返回对应元素,如果为空返回undefined。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getLast method cannot be bound. |
**示例:**
```
ts
...
...
@@ -625,6 +937,11 @@ linkedList.add(4);
linkedList
.
add
(
5
);
linkedList
.
add
(
4
);
linkedList
.
getLast
();
try
{
linkedList
.
getLast
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### [Symbol.iterator]
...
...
@@ -641,6 +958,14 @@ linkedList.getLast();
| -------- | -------- |
| IterableIterator
<
T
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
**示例:**
```
ts
...
...
@@ -662,4 +987,9 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
try
{
linkedList
[
Symbol
.
iterator
].
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zh-cn/application-dev/reference/apis/js-apis-list.md
浏览文件 @
db4817c2
...
...
@@ -38,11 +38,23 @@ List的构造函数。
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200012 | The List's constructor cannot be directly invoked. |
**示例:**
```
ts
let
list
=
new
List
();
try
{
let
list2
=
List
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -66,6 +78,14 @@ add(element: T): boolean
| -------- | -------- |
| boolean | 插入成功返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The add method cannot be bound. |
**示例:**
```
ts
...
...
@@ -76,6 +96,11 @@ let b = [1, 2, 3];
list
.
add
(
b
);
let
c
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
let
result3
=
list
.
add
(
false
);
try
{
list
.
add
.
bind
({},
"
b
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### insert
...
...
@@ -93,6 +118,15 @@ insert(element: T, index: number): void
| element | T | 是 | 插入元素。 |
| index | number | 是 | 插入的位置索引。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The insert method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -100,6 +134,16 @@ let list = new List();
list
.
insert
(
"
A
"
,
0
);
list
.
insert
(
0
,
1
);
list
.
insert
(
true
,
2
);
try
{
list
.
insert
.
bind
({},
"
b
"
,
3
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
list
.
insert
(
"
b
"
,
6
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### has
...
...
@@ -122,6 +166,14 @@ has(element: T): boolean
| -------- | -------- |
| boolean | 包含指定元素返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The has method cannot be bound. |
**示例:**
```
ts
...
...
@@ -129,6 +181,11 @@ let list = new List();
let
result
=
list
.
has
(
"
squirrel
"
);
list
.
add
(
"
squirrel
"
);
let
result1
=
list
.
has
(
"
squirrel
"
);
try
{
list
.
has
.
bind
({},
"
squirrel
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### get
...
...
@@ -151,6 +208,14 @@ get(index: number): T
| -------- | -------- |
| T | 根据下标查找到的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The get method cannot be bound. |
**示例:**
```
ts
...
...
@@ -163,6 +228,11 @@ list.add(1);
list
.
add
(
2
);
list
.
add
(
4
);
let
result
=
list
.
get
(
2
);
try
{
list
.
get
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getLastIndexOf
...
...
@@ -185,6 +255,14 @@ getLastIndexOf(element: T): number
| -------- | -------- |
| number | 返回指定元素最后一次出现的下标值,没有找到返回-1。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getLastIndexOf method cannot be bound. |
**示例:**
```
ts
...
...
@@ -197,6 +275,11 @@ list.add(1);
list
.
add
(
2
);
list
.
add
(
4
);
let
result
=
list
.
getLastIndexOf
(
2
);
try
{
list
.
getLastIndexOf
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getIndexOf
...
...
@@ -219,6 +302,14 @@ getIndexOf(element: T): number
| -------- | -------- |
| number | 返回第一次找到指定元素的下标,没有找到返回-1。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getIndexOf method cannot be bound. |
**示例:**
```
ts
...
...
@@ -232,6 +323,11 @@ list.add(2);
list
.
add
(
4
);
list
.
getIndexOf
(
2
);
let
result
=
list
.
getIndexOf
(
2
);
try
{
list
.
getIndexOf
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### equal
...
...
@@ -254,6 +350,14 @@ equal(obj: Object): boolean
| -------- | -------- |
| boolean | 如果对象与此列表相同返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The equal method cannot be bound. |
**示例:**
```
ts
...
...
@@ -269,6 +373,11 @@ obj1.add(5);
list
.
equal
(
obj1
);
let
obj2
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
let
result
=
list
.
equal
(
obj2
);
try
{
list
.
equal
.
bind
({},
obj2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### removeByIndex
...
...
@@ -291,6 +400,15 @@ removeByIndex(index: number): T
| -------- | -------- |
| T | 返回删除的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The removeByIndex method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -301,6 +419,16 @@ list.add(5);
list
.
add
(
2
);
list
.
add
(
4
);
let
result
=
list
.
removeByIndex
(
2
);
try
{
list
.
removeByIndex
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
list
.
removeByIndex
(
8
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### remove
...
...
@@ -323,6 +451,14 @@ remove(element: T): boolean
| -------- | -------- |
| boolean | 删除成功返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The remove method cannot be bound. |
**示例:**
```
ts
...
...
@@ -332,6 +468,11 @@ list.add(4);
list
.
add
(
5
);
list
.
add
(
4
);
let
result
=
list
.
remove
(
2
);
try
{
list
.
remove
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### replaceAllElements
...
...
@@ -358,6 +499,14 @@ callbackfn的参数说明:
| index | number | 否 | 当前遍历到的下标值。 |
| list | List
<
T
>
| 否 | 当前调用replaceAllElements方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The replaceAllElements method cannot be bound. |
**示例:**
```
ts
...
...
@@ -372,6 +521,13 @@ list.replaceAllElements((value: number, index: number) => {
list
.
replaceAllElements
((
value
:
number
,
index
:
number
)
=>
{
return
value
=
value
-
2
;
});
try
{
list
.
replaceAllElements
.
bind
({},
(
value
:
number
,
index
:
number
)
=>
{
return
value
=
2
*
value
;
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### forEach
...
...
@@ -398,6 +554,14 @@ callbackfn的参数说明:
| index | number | 否 | 当前遍历到的下标值。 |
| List | List
<
T
>
| 否 | 当前调用forEach方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The forEach method cannot be bound. |
**示例:**
```
ts
...
...
@@ -409,6 +573,13 @@ list.add(4);
list
.
forEach
((
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
index
);
});
try
{
list
.
forEach
.
bind
({},
(
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
index
);
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -433,6 +604,14 @@ comparator的参数说明:
| firstValue | T | 是 | 前一项元素。 |
| secondValue | T | 是 | 后一项元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The sort method cannot be bound. |
**示例:**
```
ts
...
...
@@ -443,6 +622,11 @@ list.add(5);
list
.
add
(
4
);
list
.
sort
((
a
:
number
,
b
:
number
)
=>
a
-
b
);
list
.
sort
((
a
:
number
,
b
:
number
)
=>
b
-
a
);
try
{
list
.
sort
.
bind
({},
(
a
:
number
,
b
:
number
)
=>
b
-
a
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getSubList
...
...
@@ -466,6 +650,15 @@ getSubList(fromIndex: number, toIndex: number): List<T>
| -------- | -------- |
| List
<
T
>
| 返回List对象实例。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getSubList method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -477,6 +670,16 @@ list.add(4);
let
result
=
list
.
getSubList
(
2
,
4
);
let
result1
=
list
.
getSubList
(
4
,
3
);
let
result2
=
list
.
getSubList
(
2
,
6
);
try
{
list
.
getSubList
.
bind
({},
2
,
4
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
list
.
getSubList
(
2
,
10
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### clear
...
...
@@ -487,6 +690,14 @@ clear(): void
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The clear method cannot be bound. |
**示例:**
```
ts
...
...
@@ -496,6 +707,11 @@ list.add(4);
list
.
add
(
5
);
list
.
add
(
4
);
list
.
clear
();
try
{
list
.
clear
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### set
...
...
@@ -519,6 +735,15 @@ set(index: number, element: T): T
| -------- | -------- |
| T | 返回替换后的元素 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The set method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -528,7 +753,16 @@ list.add(4);
list
.
add
(
5
);
list
.
add
(
4
);
list
.
set
(
2
,
"
b
"
);
try
{
list
.
set
.
bind
({},
3
,
"
b
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
list
.
set
(
8
,
"
b
"
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### convertToArray
...
...
@@ -545,6 +779,14 @@ convertToArray(): Array<T>
| -------- | -------- |
| Array
<
T
>
| 返回转换后的数组。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The convertToArray method cannot be bound. |
**示例:**
```
ts
...
...
@@ -554,6 +796,11 @@ list.add(4);
list
.
add
(
5
);
list
.
add
(
4
);
let
result
=
list
.
convertToArray
();
try
{
list
.
convertToArray
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### isEmpty
...
...
@@ -570,6 +817,14 @@ isEmpty(): boolean
| -------- | -------- |
| boolean | 为空返回true,不为空返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The isEmpty method cannot be bound. |
**示例:**
```
ts
...
...
@@ -579,6 +834,11 @@ list.add(4);
list
.
add
(
5
);
list
.
add
(
4
);
let
result
=
list
.
isEmpty
();
try
{
list
.
isEmpty
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getFirst
...
...
@@ -595,6 +855,14 @@ getFirst(): T
| -------- | -------- |
| T | 返回实例的第一个元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getFirst method cannot be bound. |
**示例:**
```
ts
...
...
@@ -604,6 +872,11 @@ list.add(4);
list
.
add
(
5
);
list
.
add
(
4
);
let
result
=
list
.
getFirst
();
try
{
list
.
getFirst
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getLast
...
...
@@ -620,6 +893,14 @@ getLast(): T
| -------- | -------- |
| T | 返回实例的最后一个元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getLast method cannot be bound. |
**示例:**
```
ts
...
...
@@ -629,6 +910,11 @@ list.add(4);
list
.
add
(
5
);
list
.
add
(
4
);
let
result
=
list
.
getLast
();
try
{
list
.
getLast
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### [Symbol.iterator]
...
...
@@ -645,6 +931,14 @@ let result = list.getLast();
| -------- | -------- |
| IterableIterator
<
T
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
**示例:**
```
ts
...
...
@@ -666,4 +960,9 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
try
{
list
[
Symbol
.
iterator
].
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zh-cn/application-dev/reference/apis/js-apis-plainarray.md
浏览文件 @
db4817c2
...
...
@@ -41,10 +41,23 @@ PlainArray的构造函数。
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200012 | The PlainArray's constructor cannot be directly invoked. |
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
try
{
let
plainArray2
=
PlainArray
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -62,11 +75,24 @@ isEmpty(): boolean
| -------- | -------- |
| boolean | 为空返回true, 不为空返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The isEmpty method cannot be bound. |
**示例:**
```
ts
const
plainArray
=
new
PlainArray
();
let
result
=
plainArray
.
isEmpty
();
try
{
plainArray
.
isEmpty
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -90,6 +116,14 @@ has(key: number): boolean
| -------- | -------- |
| boolean | 包含指定key返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The has method cannot be bound. |
**示例:**
```
ts
...
...
@@ -97,6 +131,11 @@ let plainArray = new PlainArray();
plainArray
.
has
(
1
);
plainArray
.
add
(
1
,
"
squirrel
"
);
let
result1
=
plainArray
.
has
(
1
);
try
{
plainArray
.
has
.
bind
({},
1
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -120,6 +159,14 @@ get(key: number): T
| -------- | -------- |
| T | 返回key映射的value值。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The get method cannot be bound. |
**示例:**
```
ts
...
...
@@ -127,6 +174,11 @@ let plainArray = new PlainArray();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
get
(
1
);
try
{
plainArray
.
get
.
bind
({},
1
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -150,6 +202,14 @@ getIndexOfKey(key: number): number
| -------- | -------- |
| number | 返回指定key第一次出现时的下标值,查找失败返回-1。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getIndexOfKey method cannot be bound. |
**示例:**
```
ts
...
...
@@ -157,6 +217,11 @@ let plainArray = new PlainArray();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
getIndexOfKey
(
2
);
try
{
plainArray
.
getIndexOfKey
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -180,6 +245,14 @@ getIndexOfValue(value: T): number
| -------- | -------- |
| number | 返回指定value元素第一次出现时的下标值,查找失败返回-1。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getIndexOfValue method cannot be bound. |
**示例:**
```
ts
...
...
@@ -187,6 +260,11 @@ let plainArray = new PlainArray();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
getIndexOfValue
(
"
squirrel
"
);
try
{
plainArray
.
getIndexOfValue
.
bind
({},
"
squirrel
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -210,6 +288,14 @@ getKeyAt(index: number): number
| -------- | -------- |
| number | 返回该下标对应的元素键值对中key值,失败返回-1。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getKeyAt method cannot be bound. |
**示例:**
```
ts
...
...
@@ -217,6 +303,11 @@ let plainArray = new PlainArray();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
getKeyAt
(
1
);
try
{
plainArray
.
getKeyAt
.
bind
({},
1
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getValueAt
...
...
@@ -239,14 +330,33 @@ getValueAt(index: number): T
| -------- | -------- |
| T | 返回该下标对应的元素键值对中key值,失败返回undefined。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getValueAt method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
getKeyAt
(
1
);
```
```
ts
let
plainArray
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
getValueAt
(
1
);
try
{
plainArray
.
getValueAt
.
bind
({},
1
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
plainArray
.
getValueAt
(
10
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### clone
...
...
@@ -262,6 +372,14 @@ clone(): PlainArray<T>
| -------- | -------- |
| PlainArray
<
T
>
| 返回新的对象实例。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The clone method cannot be bound. |
**示例:**
```
ts
...
...
@@ -269,6 +387,11 @@ let plainArray = new PlainArray();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
newPlainArray
=
plainArray
.
clone
();
try
{
plainArray
.
clone
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -287,11 +410,24 @@ add(key: number, value: T): void
| key | number | 是 | 添加成员数据的键名。 |
| value | T | 是 | 添加成员数据的值。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The add method cannot be bound. |
**示例:**
```
ts
let
plainArray
=
new
PlainArray
();
plainArray
.
add
(
1
,
"
squirrel
"
);
try
{
plainArray
.
add
.
bind
({},
"
squirrel
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -315,6 +451,14 @@ remove(key: number): T
| -------- | -------- |
| T | 返回删除元素的值。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The remove method cannot be bound. |
**示例:**
```
ts
...
...
@@ -323,6 +467,11 @@ plainArray.add(1, "squirrel");
plainArray
.
add
(
2
,
"
sparrow
"
);
plainArray
.
remove
(
2
);
let
result
=
plainArray
.
remove
(
2
);
try
{
plainArray
.
remove
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -346,6 +495,14 @@ removeAt(index: number): T
| -------- | -------- |
| T | 返回删除的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The removeAt method cannot be bound. |
**示例:**
```
ts
...
...
@@ -354,6 +511,11 @@ plainArray.add(1, "squirrel");
plainArray
.
add
(
2
,
"
sparrow
"
);
plainArray
.
removeAt
(
1
);
let
result
=
plainArray
.
removeAt
(
1
);
try
{
plainArray
.
removeAt
.
bind
({},
1
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -378,6 +540,15 @@ removeRangeFrom(index: number, size: number): number
| -------- | -------- |
| number | 实际删除元素个数。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The removeRangeFrom method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -385,6 +556,16 @@ let plainArray = new PlainArray();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
removeRangeFrom
(
1
,
3
);
try
{
plainArray
.
removeRangeFrom
.
bind
({},
1
,
3
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
plainArray
.
removeRangeFrom
(
10
,
3
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -403,6 +584,15 @@ setValueAt(index: number, value: T): void
| index | number | 是 | 指定替换数据下标。 |
| value | T | 是 | 替换键值对中的值。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The setValueAt method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
**示例:**
```
ts
...
...
@@ -410,6 +600,16 @@ let plainArray = new PlainArray();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
plainArray
.
setValueAt
(
1
,
3546
);
try
{
plainArray
.
setValueAt
.
bind
({},
1
,
3546
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
try
{
plainArray
.
setValueAt
(
10
,
3
);
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -427,6 +627,14 @@ toString(): String
| -------- | -------- |
| String | 返回对应字符串。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The toString method cannot be bound. |
**示例:**
```
ts
...
...
@@ -434,6 +642,11 @@ let plainArray = new PlainArray();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
let
result
=
plainArray
.
toString
();
try
{
plainArray
.
toString
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -445,6 +658,14 @@ clear(): void
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The clear method cannot be bound. |
**示例:**
```
ts
...
...
@@ -452,6 +673,11 @@ let plainArray = new PlainArray();
plainArray
.
add
(
1
,
"
squirrel
"
);
plainArray
.
add
(
2
,
"
sparrow
"
);
plainArray
.
clear
();
try
{
plainArray
.
clear
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -477,6 +703,14 @@ callbackfn的参数说明:
| index | number | 否 | 当前遍历到的元素键值对的键。 |
| PlainArray | PlainArray
<
T
>
| 否 | 当前调用forEach方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The forEach method cannot be bound. |
**示例:**
```
ts
...
...
@@ -486,6 +720,13 @@ plainArray.add(2, "sparrow");
plainArray
.
forEach
((
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
index
);
});
try
{
plainArray
.
forEach
.
bind
({},
(
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
index
);
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -503,6 +744,14 @@ plainArray.forEach((value, index) => {
| -------- | -------- |
| IterableIterator
<
[number, T]
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
**示例:**
```
ts
...
...
@@ -524,4 +773,9 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
[
1
]);
temp
=
iter
.
next
().
value
;
}
try
{
plainArray
[
Symbol
.
iterator
].
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zh-cn/application-dev/reference/apis/js-apis-queue.md
浏览文件 @
db4817c2
...
...
@@ -38,10 +38,23 @@ Queue的构造函数。
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200012 | The Queue's constructor cannot be directly invoked. |
**示例:**
```
ts
let
queue
=
new
Queue
();
try
{
let
queue2
=
Queue
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -65,6 +78,14 @@ add(element: T): boolean
| -------- | -------- |
| boolean | 插入成功返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The add method cannot be bound. |
**示例:**
```
ts
...
...
@@ -76,6 +97,11 @@ let b = [1, 2, 3];
queue
.
add
(
b
);
let
c
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
let
result3
=
queue
.
add
(
c
);
try
{
queue
.
add
.
bind
({},
"
b
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### pop
...
...
@@ -92,6 +118,14 @@ pop(): T
| -------- | -------- |
| T | 返回删除的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The pop method cannot be bound. |
**示例:**
```
ts
...
...
@@ -102,6 +136,11 @@ queue.add(5);
queue
.
add
(
2
);
queue
.
add
(
4
);
let
result
=
queue
.
pop
();
try
{
queue
.
pop
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### getFirst
...
...
@@ -118,6 +157,14 @@ getFirst(): T
| -------- | -------- |
| T | 返回获取的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getFirst method cannot be bound. |
**示例:**
```
ts
...
...
@@ -127,6 +174,11 @@ queue.add(4);
queue
.
add
(
5
);
queue
.
add
(
2
);
let
result
=
queue
.
getFirst
();
try
{
queue
.
getFirst
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### forEach
...
...
@@ -153,6 +205,14 @@ callbackfn的参数说明:
| index | number | 否 | 当前遍历到的下标值。 |
| Queue | Queue
<
T
>
| 否 | 当前调用forEach方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The forEach method cannot be bound. |
**示例:**
```
ts
...
...
@@ -164,7 +224,13 @@ queue.add(4);
queue
.
forEach
((
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
index
);
});
try
{
queue
.
forEach
.
bind
({},
(
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
index
);
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### [Symbol.iterator]
...
...
@@ -181,6 +247,14 @@ queue.forEach((value, index) => {
| -------- | -------- |
| IterableIterator
<
T
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
**示例:**
```
ts
let
queue
=
new
Queue
();
...
...
@@ -201,4 +275,9 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
try
{
queue
[
Symbol
.
iterator
].
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zh-cn/application-dev/reference/apis/js-apis-stack.md
浏览文件 @
db4817c2
...
...
@@ -40,10 +40,23 @@ Stack的构造函数。
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200012 | The Stack's constructor cannot be directly invoked. |
**示例:**
```
ts
let
stack
=
new
Stack
();
try
{
let
stack2
=
Stack
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -67,6 +80,14 @@ push(item: T): T
| -------- | -------- |
| T | 返回被添加进去的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The push method cannot be bound. |
**示例:**
```
ts
...
...
@@ -77,6 +98,11 @@ let b = [1, 2, 3];
stack
.
push
(
b
);
let
c
=
{
name
:
"
Dylon
"
,
age
:
"
13
"
};
let
result3
=
stack
.
push
(
c
);
try
{
stack
.
push
.
bind
({},
"
b
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### pop
...
...
@@ -93,6 +119,14 @@ pop(): T
| -------- | -------- |
| T | 返回删除的元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The pop method cannot be bound. |
**示例:**
```
ts
...
...
@@ -103,6 +137,11 @@ stack.push(5);
stack
.
push
(
2
);
stack
.
push
(
4
);
let
result
=
stack
.
pop
();
try
{
stack
.
pop
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### peek
...
...
@@ -119,6 +158,14 @@ peek(): T
| -------- | -------- |
| T | 返回栈顶元素。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The peek method cannot be bound. |
**示例:**
```
ts
...
...
@@ -128,6 +175,11 @@ stack.push(4);
stack
.
push
(
5
);
stack
.
push
(
2
);
let
result
=
stack
.
peek
();
try
{
stack
.
peek
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### locate
...
...
@@ -150,6 +202,14 @@ locate(element: T): number
| -------- | -------- |
| number | 找到就返回下标值,查找失败返回-1。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The locate method cannot be bound. |
**示例:**
```
ts
...
...
@@ -159,6 +219,11 @@ stack.push(4);
stack
.
push
(
5
);
stack
.
push
(
2
);
let
result
=
stack
.
locate
(
2
);
try
{
stack
.
locate
.
bind
({},
2
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### forEach
...
...
@@ -185,6 +250,14 @@ callbackfn的参数说明:
| index | number | 否 | 当前遍历到的下标值。 |
| stack | Stack
<
T
>
| 否 | 当前调用forEach方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The forEach method cannot be bound. |
**示例:**
```
ts
...
...
@@ -196,6 +269,13 @@ stack.push(4);
stack
.
forEach
((
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
index
);
});
try
{
stack
.
forEach
.
bind
({},
(
value
,
index
)
=>
{
console
.
log
(
"
value:
"
+
value
,
index
);
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### isEmpty
...
...
@@ -212,6 +292,14 @@ isEmpty(): boolean
| -------- | -------- |
| boolean | 为空返回true,不为空返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The isEmpty method cannot be bound. |
**示例:**
```
ts
...
...
@@ -221,6 +309,11 @@ stack.push(4);
stack
.
push
(
5
);
stack
.
push
(
4
);
let
result
=
stack
.
isEmpty
();
try
{
stack
.
isEmpty
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### [Symbol.iterator]
...
...
@@ -237,6 +330,14 @@ let result = stack.isEmpty();
| -------- | -------- |
| IterableIterator
<
T
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
**示例:**
```
ts
let
stack
=
new
Stack
();
...
...
@@ -257,4 +358,9 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
try
{
stack
[
Symbol
.
iterator
].
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zh-cn/application-dev/reference/apis/js-apis-treemap.md
浏览文件 @
db4817c2
...
...
@@ -46,10 +46,23 @@ TreeMap的构造函数。
| -------- | -------- | -------- | -------- |
| comparator | function | 否 | 用户自定义的比较函数。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200012 | The TreeMap's constructor cannot be directly invoked. |
**示例:**
```
ts
let
treeMap
=
new
TreeMap
();
try
{
let
treeMap2
=
TreeMap
();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -67,11 +80,24 @@ isEmpty(): boolean
| -------- | -------- |
| boolean | 为空返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The isEmpty method cannot be bound. |
**示例:**
```
ts
const
treeMap
=
new
TreeMap
();
let
result
=
treeMap
.
isEmpty
();
try
{
treeMap
.
isEmpty
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -95,6 +121,14 @@ hasKey(key: K): boolean
| -------- | -------- |
| boolean | 包含指定key返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The hasKey method cannot be bound. |
**示例:**
```
ts
...
...
@@ -102,6 +136,11 @@ let treeMap = new TreeMap();
let
result
=
treeMap
.
hasKey
(
"
squirrel
"
);
treeMap
.
set
(
"
squirrel
"
,
123
);
let
result1
=
treeMap
.
hasKey
(
"
squirrel
"
);
try
{
treeMap
.
hasKey
.
bind
({},
"
squirrel
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -125,6 +164,14 @@ hasValue(value: V): boolean
| -------- | -------- |
| boolean | 包含指定元素返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The hasValue method cannot be bound. |
**示例:**
```
ts
...
...
@@ -132,6 +179,11 @@ let treeMap = new TreeMap();
let
result
=
treeMap
.
hasValue
(
123
);
treeMap
.
set
(
"
squirrel
"
,
123
);
let
result1
=
treeMap
.
hasValue
(
123
);
try
{
treeMap
.
hasValue
.
bind
({},
123
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -155,6 +207,14 @@ get(key: K): V
| -------- | -------- |
| V | 返回key映射的value值。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The get method cannot be bound. |
**示例:**
```
ts
...
...
@@ -162,6 +222,11 @@ let treeMap = new TreeMap();
treeMap
.
set
(
"
squirrel
"
,
123
);
treeMap
.
set
(
"
sparrow
"
,
356
);
let
result
=
treeMap
.
get
(
"
sparrow
"
);
try
{
treeMap
.
get
.
bind
({},
"
sparrow
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -179,6 +244,14 @@ getFirstKey(): K
| -------- | -------- |
| K | 返回排序第一的key。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getFirstKey method cannot be bound. |
**示例:**
```
ts
...
...
@@ -186,6 +259,11 @@ let treeMap = new TreeMap();
treeMap
.
set
(
"
squirrel
"
,
123
);
treeMap
.
set
(
"
sparrow
"
,
356
);
let
result
=
treeMap
.
getFirstKey
();
try
{
treeMap
.
getFirstKey
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -203,6 +281,14 @@ getLastKey(): K
| -------- | -------- |
| K | 返回排序最后的key |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getLastKey method cannot be bound. |
**示例:**
```
ts
...
...
@@ -210,6 +296,11 @@ let treeMap = new TreeMap();
treeMap
.
set
(
"
squirrel
"
,
123
);
treeMap
.
set
(
"
sparrow
"
,
356
);
let
result
=
treeMap
.
getLastKey
();
try
{
treeMap
.
getLastKey
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -227,6 +318,14 @@ setAll(map: TreeMap<K, V>): void
| -------- | -------- | -------- | -------- |
| map | TreeMap
<K
,
V
>
| 是 | 被添加元素的treeMap。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The setAll method cannot be bound. |
**示例:**
```
ts
...
...
@@ -235,6 +334,11 @@ treeMap.set("squirrel", 123);
treeMap
.
set
(
"
sparrow
"
,
356
);
let
map
=
new
TreeMap
();
treeMap
.
setAll
(
map
);
try
{
treeMap
.
setAll
.
bind
({},
map
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -259,11 +363,24 @@ set(key: K, value: V): Object
| -------- | -------- |
| Object | 返回添加后的treeMap |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The set method cannot be bound. |
**示例:**
```
ts
let
treeMap
=
new
TreeMap
();
treeMap
.
set
(
"
squirrel
"
,
123
);
try
{
treeMap
.
set
.
bind
({},
"
squirrel
"
,
123
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -287,6 +404,14 @@ remove(key: K): V
| -------- | -------- |
| V | 返回删除元素的值。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The remove method cannot be bound. |
**示例:**
```
ts
...
...
@@ -294,6 +419,11 @@ let treeMap = new TreeMap();
treeMap
.
set
(
"
squirrel
"
,
123
);
treeMap
.
set
(
"
sparrow
"
,
356
);
treeMap
.
remove
(
"
sparrow
"
);
try
{
treeMap
.
remove
.
bind
({},
"
sparrow
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -317,6 +447,14 @@ getLowerKey(key: K): K
| -------- | -------- |
| K | 返回排序中key前一位的数据。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getLowerKey method cannot be bound. |
**示例:**
```
ts
...
...
@@ -325,6 +463,11 @@ treeMap.set("squirrel", 123);
treeMap
.
set
(
"
sparrow
"
,
356
);
treeMap
.
set
(
"
gander
"
,
356
);
let
result
=
treeMap
.
getLowerKey
(
"
sparrow
"
);
try
{
treeMap
.
getLowerKey
.
bind
({},
"
sparrow
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -348,6 +491,14 @@ getHigherKey(key: K): K
| -------- | -------- |
| K | 返回排序中key后一位的数据。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The getHigherKey method cannot be bound. |
**示例:**
```
ts
...
...
@@ -356,6 +507,11 @@ treeMap.set("squirrel", 123);
treeMap
.
set
(
"
sparrow
"
,
356
);
treeMap
.
set
(
"
gander
"
,
356
);
let
result
=
treeMap
.
getHigherKey
(
"
sparrow
"
);
try
{
treeMap
.
getHigherKey
.
bind
({},
"
sparrow
"
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
### replace
...
...
@@ -379,12 +535,25 @@ replace(key: K, newValue: V): boolean
| -------- | -------- |
| boolean | 对指定key对应的元素替换成功返回true,否则返回false。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The replace method cannot be bound. |
**示例:**
```
ts
let
treeMap
=
new
TreeMap
();
treeMap
.
set
(
"
sparrow
"
,
123
);
let
result
=
treeMap
.
replace
(
"
sparrow
"
,
357
);
try
{
treeMap
.
replace
.
bind
({},
"
sparrow
"
,
357
)();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -396,6 +565,14 @@ clear(): void
**系统能力:**
SystemCapability.Utils.Lang
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The clear method cannot be bound. |
**示例:**
```
ts
...
...
@@ -403,6 +580,11 @@ let treeMap = new TreeMap();
treeMap
.
set
(
"
squirrel
"
,
123
);
treeMap
.
set
(
"
sparrow
"
,
356
);
treeMap
.
clear
();
try
{
treeMap
.
clear
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -420,6 +602,14 @@ keys(): IterableIterator<K>
| -------- | -------- |
| IterableIterator
<
K
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The keys method cannot be bound. |
**示例:**
```
ts
...
...
@@ -431,7 +621,12 @@ let temp = iter.next().value;
while
(
temp
!=
undefined
)
{
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
}
try
{
treeMap
.
keys
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -449,6 +644,14 @@ values(): IterableIterator<V>
| -------- | -------- |
| IterableIterator
<
V
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The values method cannot be bound. |
**示例:**
```
ts
...
...
@@ -461,6 +664,11 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
);
temp
=
iter
.
next
().
value
;
}
try
{
treeMap
.
values
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -486,6 +694,14 @@ callbackfn的参数说明:
| key | K | 否 | 当前遍历到的元素键值对的键。 |
| map | TreeMap
<K
,
V
>
| 否 | 当前调用forEach方法的实例对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The forEach method cannot be bound. |
**示例:**
```
ts
...
...
@@ -495,6 +711,13 @@ treeMap.set("gull", 357);
treeMap
.
forEach
((
value
,
key
)
=>
{
console
.
log
(
"
value:
"
+
value
,
key
);
});
try
{
treeMap
.
forEach
.
bind
({},
(
value
,
key
)
=>
{
console
.
log
(
"
value:
"
+
value
,
key
);
})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -512,6 +735,14 @@ entries(): IterableIterator<[K, V]>
| -------- | -------- |
| IterableIterator
<
[
K
,
V
]
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The entries method cannot be bound. |
**示例:**
```
ts
...
...
@@ -525,6 +756,11 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
[
1
]);
temp
=
iter
.
next
().
value
;
}
try
{
treeMap
.
entries
.
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
...
...
@@ -541,6 +777,14 @@ while(temp != undefined) {
| -------- | -------- |
| IterableIterator
<
[
K
,
V
]
>
| 返回一个迭代器。 |
**错误码:**
以下错误码的详细介绍请参见
[
containers错误码
](
../errorcodes/errorcode-containers.md
)
。
| 错误码ID | 错误码信息 |
| -------- | -------- |
| 10200011 | The Symbol.iterator method cannot be bound. |
**示例:**
```
ts
...
...
@@ -562,4 +806,9 @@ while(temp != undefined) {
console
.
log
(
"
value:
"
+
temp
[
1
]);
temp
=
iter
.
next
().
value
;
}
try
{
treeMap
[
Symbol
.
iterator
].
bind
({})();
}
catch
(
err
)
{
console
.
log
(
`
${
err
.
code
}
-
${
err
.
name
}
-
${
err
.
message
}
`
);
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zh-cn/application-dev/reference/apis/js-apis-treeset.md
浏览文件 @
db4817c2
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/errorcodes/errorcode-containers.md
0 → 100644
浏览文件 @
db4817c2
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
反馈
建议
客服
返回
顶部