提交 db4817c2 编写于 作者: L liu-ganlin

add containers exception information

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