提交 e23fbcf8 编写于 作者: G Gloria

Update docs against 11818+11950+11998

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 0ed48d81
# Linear Container ArrayList
# @ohos.util.ArrayList (Linear Container ArrayList)
> **NOTE**
>
......@@ -52,11 +52,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let arrayList = new ArrayList();
try {
let arrayList2 = ArrayList();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -90,21 +85,16 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
**Example**
```ts
let arrayList = new ArrayList();
let result = arrayList.add("a");
let result1 = arrayList.add(1);
let b = [1, 2, 3];
let result2 = arrayList.add(b);
let c = {name: "Dylon", age: "13"};
let result3 = arrayList.add(c);
let result4 = arrayList.add(false);
try {
arrayList.add.bind({}, "b")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
```ts
let arrayList = new ArrayList();
let result = arrayList.add("a");
let result1 = arrayList.add(1);
let b = [1, 2, 3];
let result2 = arrayList.add(b);
let c = {name: "Dylon", age: "13"};
let result3 = arrayList.add(c);
let result4 = arrayList.add(false);
```
### insert
......@@ -128,7 +118,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The insert method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -137,21 +127,6 @@ let arrayList = new ArrayList();
arrayList.insert("A", 0);
arrayList.insert(0, 1);
arrayList.insert(true, 2);
try {
arrayList.insert.bind({}, 1, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
try {
let res = arrayList.insert (8, 11); // Trigger an out-of-bounds exception.
} catch (err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
try {
let res = arrayList.insert("a", "b"); // Trigger a type exception.
} catch (err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### has
......@@ -189,11 +164,6 @@ let arrayList = new ArrayList();
let result = arrayList.has("squirrel");
arrayList.add("squirrel");
let result1 = arrayList.has("squirrel");
try {
arrayList.has.bind({}, "squirrel")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getIndexOf
......@@ -236,11 +206,6 @@ arrayList.add(1);
arrayList.add(2);
arrayList.add(4);
let result = arrayList.getIndexOf(2);
try {
arrayList.getIndexOf.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getLastIndexOf
......@@ -283,11 +248,6 @@ arrayList.add(1);
arrayList.add(2);
arrayList.add(4);
let result = arrayList.getLastIndexOf(2);
try {
arrayList.getLastIndexOf.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### removeByIndex
......@@ -317,7 +277,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeByIndex method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -329,21 +289,6 @@ arrayList.add(5);
arrayList.add(2);
arrayList.add(4);
let result = arrayList.removeByIndex(2);
try {
arrayList.removeByIndex.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
try {
arrayList.removeByIndex("a"); // Trigger a type exception.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
try {
arrayList.removeByIndex(8); // Trigger an out-of-bounds exception.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### remove
......@@ -383,11 +328,6 @@ arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
let result = arrayList.remove(2);
try {
arrayList.remove.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### removeByRange
......@@ -412,7 +352,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeByRange method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -423,21 +363,11 @@ arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
arrayList.removeByRange(2, 4);
try {
arrayList.removeByRange.bind({}, 2, 4)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
try {
arrayList.removeByRange(8, 4); // Trigger an out-of-bounds exception.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### replaceAllElements
replaceAllElements(callbackfn: (value: T, index?: number, arrlist?: ArrayList&lt;T&gt;) => T,
replaceAllElements(callbackFn: (value: T, index?: number, arrlist?: ArrayList&lt;T&gt;) => T,
thisArg?: Object): void
Replaces all elements in this container with new elements, and returns the new ones.
......@@ -448,7 +378,7 @@ Replaces all elements in this container with new elements, and returns the new o
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked for the replacement.|
| callbackFn | function | Yes| Callback invoked for the replacement.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -481,18 +411,11 @@ arrayList.replaceAllElements((value: number, index: number)=> {
arrayList.replaceAllElements((value: number, index: number) => {
return value = value - 2;
});
try {
arrayList.replaceAllElements.bind({}, (value: number, index: number)=> {
return value = 2 * value;
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value: T, index?: number, arrlist?: ArrayList&lt;T&gt;) => void,
forEach(callbackFn: (value: T, index?: number, arrlist?: ArrayList&lt;T&gt;) => void,
thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -503,7 +426,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -533,13 +456,6 @@ arrayList.add(4);
arrayList.forEach((value, index) => {
console.log(`value:${value}`, index);
});
try {
arrayList.forEach.bind({}, (value, index) => {
console.log(`value:${value}`, index);
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### sort
......@@ -582,11 +498,6 @@ arrayList.add(4);
arrayList.sort((a: number, b: number) => a - b);
arrayList.sort((a: number, b: number) => b - a);
arrayList.sort();
try {
arrayList.sort.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### subArrayList
......@@ -617,7 +528,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The subArrayList method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -630,16 +541,6 @@ arrayList.add(4);
let result1 = arrayList.subArrayList(2, 4);
let result2 = arrayList.subArrayList(4, 3);
let result3 = arrayList.subArrayList(2, 6);
try {
arrayList.subArrayList.bind({}, 2, 4)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} 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
......@@ -667,11 +568,6 @@ arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
arrayList.clear();
try {
arrayList.clear.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### clone
......@@ -706,11 +602,6 @@ arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
let result = arrayList.clone();
try {
arrayList.clone.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getCapacity
......@@ -744,11 +635,6 @@ arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
let result = arrayList.getCapacity();
try {
arrayList.getCapacity.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### convertToArray
......@@ -782,11 +668,6 @@ arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
let result = arrayList.convertToArray();
try {
arrayList.convertToArray.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### isEmpty
......@@ -820,11 +701,6 @@ arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
let result = arrayList.isEmpty();
try {
arrayList.isEmpty.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### increaseCapacityTo
......@@ -859,11 +735,6 @@ arrayList.add(5);
arrayList.add(4);
arrayList.increaseCapacityTo(2);
arrayList.increaseCapacityTo(8);
try {
arrayList.increaseCapacityTo.bind({}, 5)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### trimToCurrentLength
......@@ -891,11 +762,6 @@ arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
arrayList.trimToCurrentLength();
try {
arrayList.trimToCurrentLength.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### [Symbol.iterator]
......@@ -941,9 +807,4 @@ while(temp != undefined) {
console.log(`value:${temp}`);
temp = iter.next().value;
}
try {
arrayList[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Linear Container Deque
# @ohos.util.Deque (Linear Container Deque)
> **NOTE**
>
......@@ -51,11 +51,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let deque = new Deque();
try {
let deque2 = Deque();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### insertFront
......@@ -91,11 +86,6 @@ deque.insertFront(b);
let c = {name : "Dylon", age : "13"};
deque.insertFront(c);
deque.insertFront(false);
try {
deque.insertFront.bind({}, "b")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### insertEnd
......@@ -131,11 +121,6 @@ deque.insertEnd(b);
let c = {name : "Dylon", age : "13"};
deque.insertEnd(c);
deque.insertEnd(false);
try {
deque.insertEnd.bind({}, "b")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### has
......@@ -173,11 +158,6 @@ let deque = new Deque();
let result = deque.has("squirrel");
deque.insertFront("squirrel");
let result1 = deque.has("squirrel");
try {
deque.has.bind({}, "b")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### popFirst
......@@ -212,11 +192,6 @@ deque.insertEnd(5);
deque.insertFront(2);
deque.insertFront(4);
let result = deque.popFirst();
try {
deque.popFirst.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### popLast
......@@ -251,16 +226,11 @@ deque.insertFront(5);
deque.insertFront(2);
deque.insertFront(4);
let result = deque.popLast();
try {
deque.popLast.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value: T, index?: number, deque?: Deque&lt;T&gt;) => void,
forEach(callbackFn: (value: T, index?: number, deque?: Deque&lt;T&gt;) => void,
thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -271,7 +241,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -301,13 +271,6 @@ deque.insertEnd(4);
deque.forEach((value, index) => {
console.log("value:" + value, index);
});
try {
deque.forEach.bind({}, (value, index) => {
console.log("value:" + value, index);
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getFirst
......@@ -341,11 +304,6 @@ deque.insertEnd(4);
deque.insertFront(5);
deque.insertFront(4);
let result = deque.getFirst();
try {
deque.getFirst.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getLast
......@@ -379,11 +337,6 @@ deque.insertFront(4);
deque.insertFront(5);
deque.insertFront(4);
let result = deque.getLast();
try {
deque.getLast.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### [Symbol.iterator]
......@@ -428,9 +381,4 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
deque[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Nonlinear Container HashMap
# @ohos.util.HashMap (Nonlinear Container HashMap)
> **NOTE**
>
......@@ -53,11 +53,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let hashMap = new HashMap();
try {
let hashMap2 = HashMap();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -88,11 +83,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
const hashMap = new HashMap();
let result = hashMap.isEmpty();
try {
hashMap.isEmpty.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -131,11 +121,6 @@ let hashMap = new HashMap();
let result = hashMap.hasKey("squirrel");
hashMap.set("squirrel", 123);
let result1 = hashMap.hasKey("squirrel");
try {
hashMap.hasKey.bind({}, "squirrel")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -174,11 +159,6 @@ let hashMap = new HashMap();
let result = hashMap.hasValue(123);
hashMap.set("squirrel", 123);
let result1 = hashMap.hasValue(123);
try {
hashMap.hasValue.bind({}, 123)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -217,11 +197,6 @@ let hashMap = new HashMap();
hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356);
let result = hashMap.get("sparrow");
try {
hashMap.get.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -255,11 +230,6 @@ hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356);
let newHashMap = new HashMap();
hashMap.setAll(newHashMap);
try {
hashMap.setAll.bind({}, newHashMap)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -297,11 +267,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let hashMap = new HashMap();
let result = hashMap.set("squirrel", 123);
try {
hashMap.set.bind({}, "squirrel", 123)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -340,11 +305,6 @@ let hashMap = new HashMap();
hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356);
let result = hashMap.remove("sparrow");
try {
hashMap.remove.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -371,11 +331,6 @@ let hashMap = new HashMap();
hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356);
hashMap.clear();
try {
hashMap.clear.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -413,11 +368,6 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
hashMap.keys.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -455,11 +405,6 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
hashMap.values.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -498,17 +443,12 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
let hashMap = new HashMap();
hashMap.set("sparrow", 123);
let result = hashMap.replace("sparrow", 357);
try {
hashMap.replace.bind({}, "sparrow", 357)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value?: V, key?: K, map?: HashMap<K, V>) => void, thisArg?: Object): void
forEach(callbackFn: (value?: V, key?: K, map?: HashMap<K, V>) => void, thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -518,7 +458,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -545,13 +485,6 @@ hashMap.set("gull", 357);
hashMap.forEach((value, key) => {
console.log("value:" + value, key);
});
try {
hashMap.forEach.bind({}, (value, key) => {
console.log("value:" + value, key);
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -590,11 +523,6 @@ while(temp != undefined) {
console.log("value:" + temp[1]);
temp = iter.next().value;
}
try {
hashMap.entries.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -621,6 +549,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| 10200011 | The Symbol.iterator method cannot be bound. |
**Example**
```ts
let hashMap = new HashMap();
hashMap.set("squirrel", 123);
......@@ -640,9 +569,4 @@ while(temp != undefined) {
console.log("value:" + temp[1]);
temp = iter.next().value;
}
try {
hashMap[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Nonlinear Container HashSet
# @ohos.util.HashSet (Nonlinear Container HashSet)
> **NOTE**
>
......@@ -61,11 +61,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let hashSet = new HashSet();
try {
let hashSet2 = HashSet();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -96,11 +91,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
const hashSet = new HashSet();
let result = hashSet.isEmpty();
try {
hashSet.isEmpty.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -139,11 +129,6 @@ let hashSet = new HashSet();
let result = hashSet.has("squirrel");
hashSet.add("squirrel");
let result1 = hashSet.has("squirrel");
try {
hashSet.has.bind({}, "squirrel")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -180,11 +165,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let hashSet = new HashSet();
let result = hashSet.add("squirrel");
try {
hashSet.add.bind({}, "squirrel")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -223,11 +203,6 @@ let hashSet = new HashSet();
hashSet.add("squirrel");
hashSet.add("sparrow");
let result = hashSet.remove("sparrow");
try {
hashSet.remove.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -254,11 +229,6 @@ let hashSet = new HashSet();
hashSet.add("squirrel");
hashSet.add("sparrow");
hashSet.clear();
try {
hashSet.remove.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -296,17 +266,12 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
hashSet.values.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value?: T, key?: T, set?: HashSet&lt;T&gt;) => void, thisArg?: Object): void
forEach(callbackFn: (value?: T, key?: T, set?: HashSet&lt;T&gt;) => void, thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -316,7 +281,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -324,7 +289,7 @@ callbackfn
| -------- | -------- | -------- | -------- |
| value | T | No| Value of the element that is currently traversed.|
| key | T | No| Key of the element that is currently traversed (same as **value**).|
| set | HashSet&lt;T&gt; | No| Instance that invokes the **forEach** method.|
| set | HashSet&lt;T&gt; | No| Instance that invokes the **forEach** API.|
**Error codes**
......@@ -343,13 +308,6 @@ hashSet.add("squirrel");
hashSet.forEach((value, key) => {
console.log("value:" + value, key);
});
try {
hashSet.forEach.bind({}, (value, key) => {
console.log("value:" + value, key);
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -387,11 +345,6 @@ while(temp != undefined) {
console.log("value:" + temp[1]);
temp = iter.next().value;
}
try {
hashSet.entries.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -436,9 +389,4 @@ while(temp != undefined) {
console.log("value: " + temp);
temp = iter.next().value;
}
try {
hashSet[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Nonlinear Container LightWeightMap
# @ohos.util.LightWeightMap (Nonlinear Container LightWeightMap)
> **NOTE**
>
......@@ -54,11 +54,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let lightWeightMap = new LightWeightMap();
try {
let lightWeightMap2 = LightWeightMap();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -89,11 +84,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
const lightWeightMap = new LightWeightMap();
let result = lightWeightMap.isEmpty();
try {
lightWeightMap.isEmpty.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -134,11 +124,6 @@ lightWeightMap.set("sparrow", 356);
let map = new LightWeightMap();
map.set("sparrow", 356);
let result = lightWeightMap.hasAll(map);
try {
lightWeightMap.hasAll.bind({}, map)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -178,11 +163,6 @@ let result = lightWeightMap.hasKey;
lightWeightMap.hasKey("squirrel");
lightWeightMap.set("squirrel", 123);
let result1 = lightWeightMap.hasKey("squirrel");
try {
lightWeightMap.hasKey.bind({}, "squirrel")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -221,11 +201,6 @@ let lightWeightMap = new LightWeightMap();
let result = lightWeightMap.hasValue(123);
lightWeightMap.set("squirrel", 123);
let result1 = lightWeightMap.hasValue(123);
try {
lightWeightMap.hasValue.bind({}, 123)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -256,11 +231,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let lightWeightMap = new LightWeightMap();
lightWeightMap.increaseCapacityTo(10);
try {
lightWeightMap.increaseCapacityTo.bind({}, 10)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -299,11 +269,6 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.get("sparrow");
try {
lightWeightMap.get.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -342,11 +307,6 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.getIndexOfKey("sparrow");
try {
lightWeightMap.getIndexOfKey.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -385,11 +345,6 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.getIndexOfValue(123);
try {
lightWeightMap.getIndexOfValue.bind({}, 123)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -420,7 +375,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The getKeyAt method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -429,16 +384,6 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.getKeyAt(1);
try {
lightWeightMap.getKeyAt.bind({}, 1)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
try {
lightWeightMap.getKeyAt(6)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -472,11 +417,6 @@ lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let map = new LightWeightMap();
lightWeightMap.setAll(map);
try {
lightWeightMap.setAll.bind({}, map)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -513,11 +453,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let lightWeightMap = new LightWeightMap();
let result = lightWeightMap.set("squirrel", 123);
try {
lightWeightMap.set.bind({}, "squirrel", 123)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -556,11 +491,6 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
lightWeightMap.remove("sparrow");
try {
lightWeightMap.remove.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -599,11 +529,6 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.removeAt(1);
try {
lightWeightMap.removeAt.bind({}, 1)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -635,7 +560,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The setValueAt method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -644,16 +569,6 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
lightWeightMap.setValueAt(1, 3546);
try {
lightWeightMap.setValueAt.bind({}, 1, 3546)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} 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}`);
}
```
......@@ -684,7 +599,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The getValueAt method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -693,16 +608,6 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let result = lightWeightMap.getValueAt(1);
try {
lightWeightMap.getValueAt.bind({}, 1)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
try {
lightWeightMap.getValueAt(6);
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -729,11 +634,6 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
lightWeightMap.clear();
try {
lightWeightMap.clear.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -771,11 +671,6 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
lightWeightMap.keys.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -813,17 +708,12 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
lightWeightMap.values.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value?: V, key?: K, map?: LightWeightMap<K, V>) => void, thisArg?: Object): void
forEach(callbackFn: (value?: V, key?: K, map?: LightWeightMap<K, V>) => void, thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -833,7 +723,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -860,13 +750,6 @@ lightWeightMap.set("gull", 357);
lightWeightMap.forEach((value, key) => {
console.log("value:" + value, key);
});
try {
lightWeightMap.forEach.bind({}, (value, key) => {
console.log("value:" + value, key);
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -905,11 +788,6 @@ while(temp != undefined) {
console.log("value:" + temp[1]);
temp = iter.next().value;
}
try {
lightWeightMap.entries.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### toString
......@@ -941,11 +819,6 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("squirrel", 123);
lightWeightMap.set("sparrow", 356);
let iter = lightWeightMap.toString();
try {
lightWeightMap.toString.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### [Symbol.iterator]
......@@ -991,9 +864,4 @@ while(temp != undefined) {
console.log("value:" + temp[1]);
temp = iter.next().value;
}
try {
lightWeightMap[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Nonlinear Container LightWeightSet
# @ohos.util.LightWeightSet (Nonlinear Container LightWeightSet)
> **NOTE**
>
......@@ -23,8 +23,6 @@ This topic uses the following to identify the use of generics:
import LightWeightSet from '@ohos.util.LightWeightSet';
```
## LightWeightSet
### Attributes
......@@ -56,11 +54,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let lightWeightSet = new LightWeightSet();
try {
let lightWeightSet2 = LightWeightSet();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -91,11 +84,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
const lightWeightSet = new LightWeightSet();
let result = lightWeightSet.isEmpty();
try {
lightWeightSet.isEmpty.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### add
......@@ -131,11 +119,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let lightWeightSet = new LightWeightSet();
let result = lightWeightSet.add("squirrel");
try {
lightWeightSet.add.bind({}, "squirrel")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -170,11 +153,6 @@ lightWeightSet.add("sparrow");
let set = new LightWeightSet();
set.add("gull");
let result = lightWeightSet.addAll(set);
try {
lightWeightSet.addAll.bind({}, set)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -215,11 +193,6 @@ lightWeightSet.add("sparrow");
let set = new LightWeightSet();
set.add("sparrow");
let result = lightWeightSet.hasAll(set);
try {
lightWeightSet.hasAll.bind({}, set)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -258,11 +231,6 @@ let lightWeightSet = new LightWeightSet();
let result = lightWeightSet.has(123);
lightWeightSet.add(123);
result = lightWeightSet.has(123);
try {
lightWeightSet.has.bind({}, 123)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -302,11 +270,6 @@ lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let obj = ["squirrel", "sparrow"];
let result = lightWeightSet.equal(obj);
try {
lightWeightSet.equal.bind({}, obj)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -331,23 +294,13 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The increaseCapacityTo method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
```ts
let lightWeightSet = new LightWeightSet();
lightWeightSet.increaseCapacityTo(10);
try {
lightWeightSet.increaseCapacityTo.bind({}, 10)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
try {
lightWeightSet.increaseCapacityTo(2);
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -386,11 +339,6 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let result = lightWeightSet.getIndexOf("sparrow");
try {
lightWeightSet.getIndexOf.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -429,11 +377,6 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let result = lightWeightSet.remove("sparrow");
try {
lightWeightSet.remove.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -472,11 +415,6 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let result = lightWeightSet.removeAt(1);
try {
lightWeightSet.removeAt.bind({}, 1)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -515,11 +453,6 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let result = lightWeightSet.getValueAt(1);
try {
lightWeightSet.getValueAt.bind({}, 1)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -546,11 +479,6 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
lightWeightSet.clear();
try {
lightWeightSet.clear.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -583,11 +511,6 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let result = lightWeightSet.toString();
try {
lightWeightSet.toString.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -620,11 +543,6 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow");
let result = lightWeightSet.toArray();
try {
lightWeightSet.toArray.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -662,17 +580,12 @@ while(index < lightWeightSet.length) {
console.log(JSON.stringify(iter.next().value));
index++;
}
try {
lightWeightSet.values.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value?: T, key?: T, set?: LightWeightSet&lt;T&gt;) => void, thisArg?: Object): void
forEach(callbackFn: (value?: T, key?: T, set?: LightWeightSet&lt;T&gt;) => void, thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -682,7 +595,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -709,13 +622,6 @@ lightWeightSet.add("gull");
lightWeightSet.forEach((value, key) => {
console.log("value:" + value, key);
});
try {
lightWeightSet.forEach.bind({}, (value, key) => {
console.log("value:" + value, key);
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -753,11 +659,6 @@ while(index < lightWeightSet.length) {
console.log(JSON.stringify(iter.next().value));
index++;
}
try {
lightWeightSet.entries.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -802,9 +703,4 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
lightWeightSet[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Linear Container LinkedList
# @ohos.util.LinkedList (Linear Container LinkedList)
> **NOTE**
>
......@@ -21,9 +21,6 @@ This topic uses the following to identify the use of generics:
import LinkedList from '@ohos.util.LinkedList';
```
## LinkedList
### Attributes
......@@ -56,11 +53,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let linkedList = new LinkedList();
try {
let linkedList2 = LinkedList();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -103,11 +95,6 @@ let result2 = linkedList.add(b);
let c = {name : "Dylon", age : "13"};
let result3 = linkedList.add(c);
let result4 = linkedList.add(false);
try {
linkedList.add.bind({}, "b")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### addFirst
......@@ -143,11 +130,6 @@ linkedList.addFirst(b);
let c = {name : "Dylon", age : "13"};
linkedList.addFirst(c);
linkedList.addFirst(false);
try {
linkedList.addFirst.bind({}, "b")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### insert
......@@ -172,7 +154,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The insert method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -181,16 +163,6 @@ let linkedList = new LinkedList();
linkedList.insert(0, "A");
linkedList.insert(1, 0);
linkedList.insert(2, true);
try {
linkedList.insert.bind({}, 3, "b")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} 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
......@@ -228,11 +200,6 @@ let linkedList = new LinkedList();
let result1 = linkedList.has("squirrel");
linkedList.add("squirrel");
let result = linkedList.has("squirrel");
try {
linkedList.has.bind({}, "squirrel")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### get
......@@ -275,11 +242,6 @@ linkedList.add(1);
linkedList.add(2);
linkedList.add(4);
let result = linkedList.get(2);
try {
linkedList.get.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getLastIndexOf
......@@ -322,11 +284,6 @@ linkedList.add(1);
linkedList.add(2);
linkedList.add(4);
let result = linkedList.getLastIndexOf(2);
try {
linkedList.getLastIndexOf.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getIndexOf
......@@ -369,11 +326,6 @@ linkedList.add(1);
linkedList.add(2);
linkedList.add(4);
let result = linkedList.getIndexOf(2);
try {
linkedList.getIndexOf.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### removeByIndex
......@@ -403,7 +355,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeByIndex method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -415,16 +367,6 @@ linkedList.add(5);
linkedList.add(2);
linkedList.add(4);
let result = linkedList.removeByIndex(2);
try {
linkedList.removeByIndex.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} 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
......@@ -448,28 +390,18 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeFirst method cannot be bound. |
| 10200010 | Container is empty. |
| 10200010 | The container is empty. |
**Example**
```ts
let linkedList = new LinkedList();
try {
linkedList.removeFirst();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
linkedList.add(2);
linkedList.add(4);
linkedList.add(5);
linkedList.add(2);
linkedList.add(4);
let result = linkedList.removeFirst();
try {
linkedList.removeFirst.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### removeLast
......@@ -493,28 +425,18 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeLast method cannot be bound. |
| 10200010 | Container is empty. |
| 10200010 | The container is empty. |
**Example**
```ts
let linkedList = new LinkedList();
try {
linkedList.removeLast();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
linkedList.add(2);
linkedList.add(4);
linkedList.add(5);
linkedList.add(2);
linkedList.add(4);
let result = linkedList.removeLast();
try {
linkedList.removeLast.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### remove
......@@ -554,11 +476,6 @@ linkedList.add(4);
linkedList.add(5);
linkedList.add(4);
let result = linkedList.remove(2);
try {
linkedList.remove.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### removeFirstFound
......@@ -588,27 +505,17 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeFirstFound method cannot be bound. |
| 10200010 | Container is empty. |
| 10200010 | The container is empty. |
**Example**
```ts
let linkedList = new LinkedList();
try {
linkedList.removeFirstFound(4);
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
linkedList.add(2);
linkedList.add(4);
linkedList.add(5);
linkedList.add(4);
let result = linkedList.removeFirstFound(4);
try {
linkedList.removeFirstFound.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### removeLastFound
......@@ -638,27 +545,17 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeLastFound method cannot be bound. |
| 10200010 | Container is empty. |
| 10200010 | The container is empty. |
**Example**
```ts
let linkedList = new LinkedList();
try {
linkedList.removeLastFound();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
linkedList.add(2);
linkedList.add(4);
linkedList.add(5);
linkedList.add(4);
let result = linkedList.removeLastFound(4);
try {
linkedList.removeLastFound.bind({}, 4)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### clone
......@@ -692,16 +589,11 @@ linkedList.add(4);
linkedList.add(5);
linkedList.add(4);
let result = linkedList.clone();
try {
linkedList.clone.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value: T, index?: number, LinkedList?: LinkedList&lt;T&gt;) => void,
forEach(callbackFn: (value: T, index?: number, LinkedList?: LinkedList&lt;T&gt;) => void,
thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -712,7 +604,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -742,13 +634,6 @@ linkedList.add(4);
linkedList.forEach((value, index) => {
console.log("value:" + value, index);
});
try {
linkedList.forEach.bind({}, (value, index) => {
console.log("value:" + value, index);
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### clear
......@@ -776,11 +661,6 @@ linkedList.add(4);
linkedList.add(5);
linkedList.add(4);
linkedList.clear();
try {
linkedList.clear.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### set
......@@ -811,7 +691,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The set method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -822,16 +702,6 @@ linkedList.add(4);
linkedList.add(5);
linkedList.add(4);
let result = linkedList.set(2, "b");
try {
linkedList.set.bind({}, 2, "b")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} 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
......@@ -864,11 +734,6 @@ linkedList.add(4);
linkedList.add(5);
linkedList.add(4);
let result = linkedList.convertToArray();
try {
linkedList.convertToArray.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getFirst
......@@ -902,11 +767,6 @@ linkedList.add(4);
linkedList.add(5);
linkedList.add(4);
let result = linkedList.getFirst();
try {
linkedList.getFirst.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getLast
......@@ -940,11 +800,6 @@ linkedList.add(4);
linkedList.add(5);
linkedList.add(4);
linkedList.getLast();
try {
linkedList.getLast.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### [Symbol.iterator]
......@@ -990,9 +845,4 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
linkedList[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Linear Container List
# @ohos.util.List (Linear Container List)
> **NOTE**
>
......@@ -51,11 +51,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let list = new List();
try {
let list2 = List();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -98,11 +93,6 @@ let result3 = list.add(b);
let c = {name : "Dylon", age : "13"};
let result4 = list.add(c);
let result5 = list.add(false);
try {
list.add.bind({}, "b")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### insert
......@@ -127,7 +117,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The insert method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -136,16 +126,6 @@ let list = new List();
list.insert("A", 0);
list.insert(0, 1);
list.insert(true, 2);
try {
list.insert.bind({}, "b", 3)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} 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
......@@ -183,11 +163,6 @@ let list = new List();
let result = list.has("squirrel");
list.add("squirrel");
let result1 = list.has("squirrel");
try {
list.has.bind({}, "squirrel")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### get
......@@ -230,11 +205,6 @@ list.add(1);
list.add(2);
list.add(4);
let result = list.get(2);
try {
list.get.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getLastIndexOf
......@@ -277,11 +247,6 @@ list.add(1);
list.add(2);
list.add(4);
let result = list.getLastIndexOf(2);
try {
list.getLastIndexOf.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getIndexOf
......@@ -325,11 +290,6 @@ list.add(2);
list.add(4);
list.getIndexOf(2);
let result = list.getIndexOf(2);
try {
list.getIndexOf.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### equal
......@@ -375,11 +335,6 @@ obj1.add(5);
list.equal(obj1);
let obj2 = {name : "Dylon", age : "13"};
let result = list.equal(obj2);
try {
list.equal.bind({}, obj2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### removeByIndex
......@@ -409,7 +364,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeByIndex method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -421,16 +376,6 @@ list.add(5);
list.add(2);
list.add(4);
let result = list.removeByIndex(2);
try {
list.removeByIndex.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} 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
......@@ -470,16 +415,11 @@ list.add(4);
list.add(5);
list.add(4);
let result = list.remove(2);
try {
list.remove.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### replaceAllElements
replaceAllElements(callbackfn: (value: T, index?: number, list?: List&lt;T&gt;) => T,
replaceAllElements(callbackFn: (value: T, index?: number, list?: List&lt;T&gt;) => T,
thisArg?: Object): void
Replaces all elements in this container with new elements, and returns the new ones.
......@@ -490,7 +430,7 @@ Replaces all elements in this container with new elements, and returns the new o
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked for the replacement.|
| callbackFn | function | Yes| Callback invoked for the replacement.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -523,18 +463,11 @@ list.replaceAllElements((value: number, index: number) => {
list.replaceAllElements((value: number, index: number) => {
return value = value - 2;
});
try {
list.replaceAllElements.bind({}, (value: number, index: number) => {
return value = 2 * value;
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value: T, index?: number, List?: List&lt;T&gt;) => void,
forEach(callbackFn: (value: T, index?: number, List?: List&lt;T&gt;) => void,
thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -545,7 +478,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -575,14 +508,6 @@ list.add(4);
list.forEach((value, index) => {
console.log("value: " + value, index);
});
try {
list.forEach.bind({}, (value, index) => {
console.log("value: " + value, index);
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### sort
......@@ -624,11 +549,6 @@ list.add(5);
list.add(4);
list.sort((a: number, b: number) => a - b);
list.sort((a: number, b: number) => b - a);
try {
list.sort.bind({}, (a: number, b: number) => b - a)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getSubList
......@@ -659,7 +579,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The getSubList method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -672,16 +592,6 @@ list.add(4);
let result = list.getSubList(2, 4);
let result1 = list.getSubList(4, 3);
let result2 = list.getSubList(2, 6);
try {
list.getSubList.bind({}, 2, 4)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} 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
......@@ -709,11 +619,6 @@ list.add(4);
list.add(5);
list.add(4);
list.clear();
try {
list.clear.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### set
......@@ -744,7 +649,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The set method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -755,16 +660,6 @@ list.add(4);
list.add(5);
list.add(4);
list.set(2, "b");
try {
list.set.bind({}, 3, "b")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} 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
......@@ -798,11 +693,6 @@ list.add(4);
list.add(5);
list.add(4);
let result = list.convertToArray();
try {
list.convertToArray.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### isEmpty
......@@ -836,11 +726,6 @@ list.add(4);
list.add(5);
list.add(4);
let result = list.isEmpty();
try {
list.isEmpty.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getFirst
......@@ -874,11 +759,6 @@ list.add(4);
list.add(5);
list.add(4);
let result = list.getFirst();
try {
list.getFirst.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getLast
......@@ -912,11 +792,6 @@ list.add(4);
list.add(5);
list.add(4);
let result = list.getLast();
try {
list.getLast.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### [Symbol.iterator]
......@@ -962,9 +837,4 @@ while(temp != undefined) {
console.log("value: " + temp);
temp = iter.next().value;
}
try {
list[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Nonlinear Container PlainArray
# @ohos.util.PlainArray (Nonlinear Container PlainArray)
> **NOTE**
>
......@@ -21,8 +21,6 @@ This topic uses the following to identify the use of generics:
import PlainArray from '@ohos.util.PlainArray';
```
## PlainArray
### Attributes
......@@ -54,11 +52,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let plainArray = new PlainArray();
try {
let plainArray2 = PlainArray();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -89,11 +82,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
const plainArray = new PlainArray();
let result = plainArray.isEmpty();
try {
plainArray.isEmpty.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -132,11 +120,6 @@ let plainArray = new PlainArray();
plainArray.has(1);
plainArray.add(1, "squirrel");
let result1 = plainArray.has(1);
try {
plainArray.has.bind({}, 1)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -175,11 +158,6 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.get(1);
try {
plainArray.get.bind({}, 1)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -218,11 +196,6 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.getIndexOfKey(2);
try {
plainArray.getIndexOfKey.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -261,11 +234,6 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.getIndexOfValue("squirrel");
try {
plainArray.getIndexOfValue.bind({}, "squirrel")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -304,11 +272,6 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.getKeyAt(1);
try {
plainArray.getKeyAt.bind({}, 1)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getValueAt
......@@ -338,7 +301,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The getValueAt method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -347,16 +310,6 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.getValueAt(1);
try {
plainArray.getValueAt.bind({}, 1)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} 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
......@@ -388,11 +341,6 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let newPlainArray = plainArray.clone();
try {
plainArray.clone.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -424,11 +372,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
try {
plainArray.add.bind({}, "squirrel")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -467,11 +410,6 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.remove(2);
try {
plainArray.remove.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -510,11 +448,6 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.removeAt(1);
try {
plainArray.removeAt.bind({}, 1)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -546,7 +479,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeRangeFrom method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -555,16 +488,6 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.removeRangeFrom(1, 3);
try {
plainArray.removeRangeFrom.bind({}, 1, 3)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} 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}`);
}
```
......@@ -590,7 +513,7 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
| ID| Error Message|
| -------- | -------- |
| 10200011 | The setValueAt method cannot be bound. |
| 10200001 | The value of parameters are out of range. |
| 10200001 | The parameter value is out of range. |
**Example**
......@@ -599,16 +522,6 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
plainArray.setValueAt(1, 3546);
try {
plainArray.setValueAt.bind({}, 1, 3546)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} 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}`);
}
```
......@@ -641,11 +554,6 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
let result = plainArray.toString();
try {
plainArray.toString.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -672,17 +580,12 @@ let plainArray = new PlainArray();
plainArray.add(1, "squirrel");
plainArray.add(2, "sparrow");
plainArray.clear();
try {
plainArray.clear.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value: T, index?: number, PlainArray?: PlainArray&lt;T&gt;) => void, thisArg?: Object): void
forEach(callbackFn: (value: T, index?: number, PlainArray?: PlainArray&lt;T&gt;) => void, thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -692,7 +595,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -719,13 +622,6 @@ plainArray.add(2, "sparrow");
plainArray.forEach((value, index) => {
console.log("value:" + value, index);
});
try {
plainArray.forEach.bind({}, (value, index) => {
console.log("value:" + value, index);
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -772,9 +668,4 @@ while(temp != undefined) {
console.log("value:" + temp[1]);
temp = iter.next().value;
}
try {
plainArray[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Linear Container Queue
# @ohos.util.Queue (Linear Container Queue)
> **NOTE**
>
......@@ -51,11 +51,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let queue = new Queue();
try {
let queue2 = Queue();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -97,11 +92,6 @@ let b = [1, 2, 3];
let result2 = queue.add(b);
let c = {name : "Dylon", age : "13"};
let result3 = queue.add(c);
try {
queue.add.bind({}, "b")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### pop
......@@ -136,11 +126,6 @@ queue.add(5);
queue.add(2);
queue.add(4);
let result = queue.pop();
try {
queue.pop.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### getFirst
......@@ -151,7 +136,7 @@ Obtains the first element of this container.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
**Return value**
| Type| Description|
| -------- | -------- |
......@@ -174,16 +159,11 @@ queue.add(4);
queue.add(5);
queue.add(2);
let result = queue.getFirst();
try {
queue.getFirst.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value: T, index?: number, Queue?: Queue&lt;T&gt;) => void,
forEach(callbackFn: (value: T, index?: number, Queue?: Queue&lt;T&gt;) => void,
thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -194,7 +174,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -224,13 +204,6 @@ queue.add(4);
queue.forEach((value, index) => {
console.log("value:" + value, index);
});
try {
queue.forEach.bind({}, (value, index) => {
console.log("value:" + value, index);
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### [Symbol.iterator]
......@@ -275,9 +248,4 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
queue[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Linear Container Stack
# @ohos.util.Stack (Linear Container Stack)
> **NOTE**
>
......@@ -19,9 +19,6 @@ This topic uses the following to identify the use of generics:
import Stack from '@ohos.util.Stack';
```
## Stack
### Attributes
......@@ -53,11 +50,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let stack = new Stack();
try {
let stack2 = Stack();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -99,11 +91,6 @@ let b = [1, 2, 3];
let result2 = stack.push(b);
let c = {name : "Dylon", age : "13"};
let result3 = stack.push(c);
try {
stack.push.bind({}, "b")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### pop
......@@ -138,11 +125,6 @@ stack.push(5);
stack.push(2);
stack.push(4);
let result = stack.pop();
try {
stack.pop.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### peek
......@@ -176,11 +158,6 @@ stack.push(4);
stack.push(5);
stack.push(2);
let result = stack.peek();
try {
stack.peek.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### locate
......@@ -220,16 +197,11 @@ stack.push(4);
stack.push(5);
stack.push(2);
let result = stack.locate(2);
try {
stack.locate.bind({}, 2)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value: T, index?: number, stack?: Stack&lt;T&gt;) => void,
forEach(callbackFn: (value: T, index?: number, stack?: Stack&lt;T&gt;) => void,
thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -240,7 +212,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -270,13 +242,6 @@ stack.push(4);
stack.forEach((value, index) => {
console.log("value:" + value, index);
});
try {
stack.forEach.bind({}, (value, index) => {
console.log("value:" + value, index);
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### isEmpty
......@@ -310,11 +275,6 @@ stack.push(4);
stack.push(5);
stack.push(4);
let result = stack.isEmpty();
try {
stack.isEmpty.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### [Symbol.iterator]
......@@ -359,9 +319,4 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
stack[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Nonlinear Container TreeMap
# @ohos.util.TreeMap (Nonlinear Container TreeMap)
> **NOTE**
>
......@@ -59,11 +59,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let treeMap = new TreeMap();
try {
let treeMap2 = TreeMap();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -94,11 +89,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
const treeMap = new TreeMap();
let result = treeMap.isEmpty();
try {
treeMap.isEmpty.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -137,11 +127,6 @@ let treeMap = new TreeMap();
let result = treeMap.hasKey("squirrel");
treeMap.set("squirrel", 123);
let result1 = treeMap.hasKey("squirrel");
try {
treeMap.hasKey.bind({}, "squirrel")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -180,11 +165,6 @@ let treeMap = new TreeMap();
let result = treeMap.hasValue(123);
treeMap.set("squirrel", 123);
let result1 = treeMap.hasValue(123);
try {
treeMap.hasValue.bind({}, 123)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -223,11 +203,6 @@ let treeMap = new TreeMap();
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
let result = treeMap.get("sparrow");
try {
treeMap.get.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -260,11 +235,6 @@ let treeMap = new TreeMap();
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
let result = treeMap.getFirstKey();
try {
treeMap.getFirstKey.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -297,11 +267,6 @@ let treeMap = new TreeMap();
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
let result = treeMap.getLastKey();
try {
treeMap.getLastKey.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -335,11 +300,6 @@ treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
let map = new TreeMap();
treeMap.setAll(map);
try {
treeMap.setAll.bind({}, map)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -377,11 +337,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let treeMap = new TreeMap();
treeMap.set("squirrel", 123);
try {
treeMap.set.bind({}, "squirrel", 123)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -420,11 +375,6 @@ let treeMap = new TreeMap();
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
treeMap.remove("sparrow");
try {
treeMap.remove.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -464,11 +414,6 @@ treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
treeMap.set("gander", 356);
let result = treeMap.getLowerKey("sparrow");
try {
treeMap.getLowerKey.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -508,11 +453,6 @@ treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
treeMap.set("gander", 356);
let result = treeMap.getHigherKey("sparrow");
try {
treeMap.getHigherKey.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### replace
......@@ -550,11 +490,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
let treeMap = new TreeMap();
treeMap.set("sparrow", 123);
let result = treeMap.replace("sparrow", 357);
try {
treeMap.replace.bind({}, "sparrow", 357)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -581,11 +516,6 @@ let treeMap = new TreeMap();
treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356);
treeMap.clear();
try {
treeMap.clear.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -623,11 +553,6 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
treeMap.keys.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -665,17 +590,12 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
treeMap.values.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value?: V, key?: K, map?: TreeMap<K, V>) => void, thisArg?: Object): void
forEach(callbackFn: (value?: V, key?: K, map?: TreeMap<K, V>) => void, thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -685,7 +605,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -712,13 +632,6 @@ treeMap.set("gull", 357);
treeMap.forEach((value, key) => {
console.log("value:" + value, key);
});
try {
treeMap.forEach.bind({}, (value, key) => {
console.log("value:" + value, key);
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -757,11 +670,6 @@ while(temp != undefined) {
console.log("value:" + temp[1]);
temp = iter.next().value;
}
try {
treeMap.entries.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -807,9 +715,4 @@ while(temp != undefined) {
console.log("value:" + temp[1]);
temp = iter.next().value;
}
try {
treeMap[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Nonlinear Container TreeSet
# @ohos.util.TreeSet (Nonlinear Container TreeSet)
> **NOTE**
>
......@@ -56,11 +56,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let treeSet = new TreeSet();
try {
let treeSet2 = TreeSet();
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -91,11 +86,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
const treeSet = new TreeSet();
let result = treeSet.isEmpty();
try {
treeSet.isEmpty.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -134,11 +124,6 @@ let treeSet = new TreeSet();
treeSet.has(123);
treeSet.add(123);
let result1 = treeSet.has(123);
try {
treeSet.has.bind({}, 123)(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -171,11 +156,6 @@ let treeSet = new TreeSet();
treeSet.add("squirrel");
treeSet.add("sparrow");
let result = treeSet.getFirstValue();
try {
treeSet.getFirstValue.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -208,11 +188,6 @@ let treeSet = new TreeSet();
treeSet.add("squirrel");
treeSet.add("sparrow");
let result = treeSet.getLastValue();
try {
treeSet.getLastValue.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -249,11 +224,6 @@ For details about the error codes, see [containers Error Codes](../errorcodes/er
```ts
let treeSet = new TreeSet();
let result = treeSet.add("squirrel");
try {
treeSet.add.bind({}, "squirrel")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -292,11 +262,6 @@ let treeSet = new TreeSet();
treeSet.add("squirrel");
treeSet.add("sparrow");
let result = treeSet.remove("sparrow");
try {
treeSet.remove.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -336,11 +301,6 @@ treeSet.add("squirrel");
treeSet.add("sparrow");
treeSet.add("gander");
let result = treeSet.getLowerValue("sparrow");
try {
treeSet.getLowerValue.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -380,11 +340,6 @@ treeSet.add("squirrel");
treeSet.add("sparrow");
treeSet.add("gander");
let result = treeSet.getHigherValue("sparrow");
try {
treeSet.getHigherValue.bind({}, "sparrow")(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -417,11 +372,6 @@ let treeSet = new TreeSet();
treeSet.add("squirrel");
treeSet.add("sparrow");
let result = treeSet.popFirst();
try {
treeSet.popFirst.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -454,11 +404,6 @@ let treeSet = new TreeSet();
treeSet.add("squirrel");
treeSet.add("sparrow");
let result = treeSet.popLast();
try {
treeSet.popLast.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -485,11 +430,6 @@ let treeSet = new TreeSet();
treeSet.add("squirrel");
treeSet.add("sparrow");
treeSet.clear();
try {
treeSet.clear.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -527,17 +467,12 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
treeSet.values.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
### forEach
forEach(callbackfn: (value?: T, key?: T, set?: TreeSet&lt;T&gt;) => void, thisArg?: Object): void
forEach(callbackFn: (value?: T, key?: T, set?: TreeSet&lt;T&gt;) => void, thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -547,7 +482,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -574,13 +509,6 @@ treeSet.add("gull");
treeSet.forEach((value, key) => {
console.log("value:" + value, key)
});
try {
treeSet.forEach.bind({}, (value, key) => {
console.log("value:" + value, key)
})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -619,11 +547,6 @@ while(temp != undefined) {
console.log("value:" + temp[1]);
temp = iter.next().value;
}
try {
treeSet.entries.bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
......@@ -668,9 +591,4 @@ while(temp != undefined) {
console.log("value:" + temp);
temp = iter.next().value;
}
try {
treeSet[Symbol.iterator].bind({})(); // bind() creates a new bound function that, when called, has its this keyword set to the provided value. It is used to test exception capture.
} catch(err) {
console.log(`${err.code} - ${err.name} - ${err.message}`);
}
```
# Linear Container Vector
# @ohos.util.Vector (Linear Container Vector)
> **NOTE**
>
......@@ -290,7 +290,7 @@ vector.removeByRange(2,4);
### replaceAllElements
replaceAllElements(callbackfn: (value: T, index?: number, vector?: Vector&lt;T&gt;) => T,
replaceAllElements(callbackFn: (value: T, index?: number, vector?: Vector&lt;T&gt;) => T,
thisArg?: Object): void
Replaces all elements in this container with new elements, and returns the new ones.
......@@ -301,7 +301,7 @@ Replaces all elements in this container with new elements, and returns the new o
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked for replacement.|
| callbackFn | function | Yes| Callback invoked for replacement.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......@@ -330,7 +330,7 @@ vector.replaceAllElements((value: number, index: number) => {
### forEach
forEach(callbackfn: (value: T, index?: number, vector?: Vector&lt;T&gt;) => void,
forEach(callbackFn: (value: T, index?: number, vector?: Vector&lt;T&gt;) => void,
thisArg?: Object): void
Uses a callback to traverse the elements in this container and obtain their position indexes.
......@@ -341,7 +341,7 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked for replacement.|
| callbackFn | function | Yes| Callback invoked for replacement.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
......
......@@ -41,7 +41,7 @@ The APIs of the **containers** class do not support **bind()**.
**Error Message**
The value of parameters are out of range.
The parameter value is out of range.
**Description**
......@@ -59,7 +59,7 @@ Use a value within the range.
**Error Message**
Container is empty.
The container is empty.
**Description**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册