未验证 提交 eb2d022d 编写于 作者: O openharmony_ci 提交者: Gitee

!17259 Problems in modifying docs data

Merge pull request !17259 from bwx1067111/master
# @ohos.util.ArrayList (线性容器ArrayList) # @ohos.util.ArrayList (线性容器ArrayList)
> **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
ArrayList是一种线性数据结构,底层基于数组实现。ArrayList会根据实际需要动态调整容量,每次扩容增加50%。 ArrayList是一种线性数据结构,底层基于数组实现。ArrayList会根据实际需要动态调整容量,每次扩容增加50%。
ArrayList和[Vector](js-apis-vector.md)相似,都是基于数组实现。它们都可以动态调整容量,但Vector每次扩容增加1倍。 ArrayList和[Vector](js-apis-vector.md)相似,都是基于数组实现。它们都可以动态调整容量,但Vector每次扩容增加1倍。
...@@ -11,8 +8,13 @@ ArrayList和[LinkedList](js-apis-linkedlist.md)相比,ArrayList的随机访问 ...@@ -11,8 +8,13 @@ ArrayList和[LinkedList](js-apis-linkedlist.md)相比,ArrayList的随机访问
**推荐使用场景:** 当需要频繁读取集合中的元素时,推荐使用ArrayList。 **推荐使用场景:** 当需要频繁读取集合中的元素时,推荐使用ArrayList。
文档中存在泛型的使用,涉及以下泛型标记符:<br> 文档中存在泛型的使用,涉及以下泛型标记符:<br>
- T: Type, 类 - T:Type,类
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
...@@ -160,9 +162,8 @@ has(element: T): boolean ...@@ -160,9 +162,8 @@ has(element: T): boolean
```ts ```ts
let arrayList = new ArrayList(); let arrayList = new ArrayList();
let result = arrayList.has("squirrel");
arrayList.add("squirrel"); arrayList.add("squirrel");
let result1 = arrayList.has("squirrel"); let result = arrayList.has("squirrel");
``` ```
### getIndexOf ### getIndexOf
...@@ -535,9 +536,7 @@ arrayList.add(2); ...@@ -535,9 +536,7 @@ arrayList.add(2);
arrayList.add(4); arrayList.add(4);
arrayList.add(5); arrayList.add(5);
arrayList.add(4); arrayList.add(4);
let result1 = arrayList.subArrayList(2, 4); let result = arrayList.subArrayList(2, 4);
let result2 = arrayList.subArrayList(4, 3);
let result3 = arrayList.subArrayList(2, 6);
``` ```
### clear ### clear
......
...@@ -417,11 +417,11 @@ isBuffer(obj: Object): boolean ...@@ -417,11 +417,11 @@ isBuffer(obj: Object): boolean
```ts ```ts
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
buffer.isBuffer(buffer.alloc(10)); // true let result = buffer.isBuffer(buffer.alloc(10)); // true
buffer.isBuffer(buffer.from('foo')); // true let result1 = buffer.isBuffer(buffer.from('foo')); // true
buffer.isBuffer('a string'); // false let result2 = buffer.isBuffer('a string'); // false
buffer.isBuffer([]); // false let result3 = buffer.isBuffer([]); // false
buffer.isBuffer(new Uint8Array(1024)); // false let result4 = buffer.isBuffer(new Uint8Array(1024)); // false
``` ```
## buffer.isEncoding ## buffer.isEncoding
...@@ -872,7 +872,7 @@ let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, ...@@ -872,7 +872,7 @@ let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
console.log(buf.readBigInt64BE(0).toString()); console.log(buf.readBigInt64BE(0).toString());
let buf1 = buffer.allocUninitializedFromPool(8); let buf1 = buffer.allocUninitializedFromPool(8);
buf1.writeBigInt64BE(0x0102030405060708n, 0); let result = buf1.writeBigInt64BE(0x0102030405060708n, 0);
``` ```
### readBigInt64LE ### readBigInt64LE
...@@ -913,7 +913,7 @@ let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, ...@@ -913,7 +913,7 @@ let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
console.log(buf.readBigInt64LE(0).toString()); console.log(buf.readBigInt64LE(0).toString());
let buf1 = buffer.allocUninitializedFromPool(8); let buf1 = buffer.allocUninitializedFromPool(8);
buf1.writeBigInt64BE(0x0102030405060708n, 0); let result = buf1.writeBigInt64BE(0x0102030405060708n, 0);
``` ```
### readBigUInt64BE ### readBigUInt64BE
...@@ -954,7 +954,7 @@ let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, ...@@ -954,7 +954,7 @@ let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
console.log(buf.readBigUInt64BE(0).toString()); console.log(buf.readBigUInt64BE(0).toString());
let buf1 = buffer.allocUninitializedFromPool(8); let buf1 = buffer.allocUninitializedFromPool(8);
buf1.writeBigUInt64BE(0xdecafafecacefaden, 0); let result = buf1.writeBigUInt64BE(0xdecafafecacefaden, 0);
``` ```
### readBigUInt64LE ### readBigUInt64LE
...@@ -995,7 +995,7 @@ let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, ...@@ -995,7 +995,7 @@ let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
console.log(buf.readBigUInt64LE(0).toString()); console.log(buf.readBigUInt64LE(0).toString());
let buf1 = buffer.allocUninitializedFromPool(8); let buf1 = buffer.allocUninitializedFromPool(8);
buf1.writeBigUInt64BE(0xdecafafecacefaden, 0); let result = buf1.writeBigUInt64BE(0xdecafafecacefaden, 0);
``` ```
### readDoubleBE ### readDoubleBE
...@@ -1035,7 +1035,7 @@ let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); ...@@ -1035,7 +1035,7 @@ let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
console.log(buf.readDoubleBE(0).toString()); console.log(buf.readDoubleBE(0).toString());
let buf1 = buffer.allocUninitializedFromPool(8); let buf1 = buffer.allocUninitializedFromPool(8);
buf1.writeDoubleBE(123.456, 0); let result = buf1.writeDoubleBE(123.456, 0);
``` ```
### readDoubleLE ### readDoubleLE
...@@ -1075,7 +1075,7 @@ let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); ...@@ -1075,7 +1075,7 @@ let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
console.log(buf.readDoubleLE(0).toString()); console.log(buf.readDoubleLE(0).toString());
let buf1 = buffer.allocUninitializedFromPool(8); let buf1 = buffer.allocUninitializedFromPool(8);
buf1.writeDoubleLE(123.456, 0); let result = buf1.writeDoubleLE(123.456, 0);
``` ```
### readFloatBE ### readFloatBE
...@@ -1115,7 +1115,7 @@ let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); ...@@ -1115,7 +1115,7 @@ let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
console.log(buf.readFloatBE(0).toString()); console.log(buf.readFloatBE(0).toString());
let buf1 = buffer.allocUninitializedFromPool(4); let buf1 = buffer.allocUninitializedFromPool(4);
buf1.writeFloatBE(0xcabcbcbc, 0); let result = buf1.writeFloatBE(0xcabcbcbc, 0);
``` ```
### readFloatLE ### readFloatLE
...@@ -1155,7 +1155,7 @@ let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); ...@@ -1155,7 +1155,7 @@ let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
console.log(buf.readFloatLE(0).toString()); console.log(buf.readFloatLE(0).toString());
let buf1 = buffer.allocUninitializedFromPool(4); let buf1 = buffer.allocUninitializedFromPool(4);
buf1.writeFloatLE(0xcabcbcbc, 0); let result = buf1.writeFloatLE(0xcabcbcbc, 0);
``` ```
### readInt8 ### readInt8
...@@ -1196,7 +1196,7 @@ console.log(buf.readInt8(0).toString()); // 打印: -1 ...@@ -1196,7 +1196,7 @@ console.log(buf.readInt8(0).toString()); // 打印: -1
console.log(buf.readInt8(1).toString()); // 打印: 5 console.log(buf.readInt8(1).toString()); // 打印: 5
let buf1 = buffer.allocUninitializedFromPool(2); let buf1 = buffer.allocUninitializedFromPool(2);
buf1.writeInt8(0x12); let result = buf1.writeInt8(0x12);
``` ```
### readInt16BE ### readInt16BE
...@@ -1236,7 +1236,7 @@ let buf = buffer.from([0, 5]); ...@@ -1236,7 +1236,7 @@ let buf = buffer.from([0, 5]);
console.log(buf.readInt16BE(0).toString()); // 打印: 5 console.log(buf.readInt16BE(0).toString()); // 打印: 5
let buf1 = buffer.alloc(2); let buf1 = buffer.alloc(2);
buf1.writeInt16BE(0x1234, 0); let result = buf1.writeInt16BE(0x1234, 0);
``` ```
### readInt16LE ### readInt16LE
...@@ -1276,7 +1276,7 @@ let buf = buffer.from([0, 5]); ...@@ -1276,7 +1276,7 @@ let buf = buffer.from([0, 5]);
console.log(buf.readInt16LE(0).toString()); // 打印: 1280 console.log(buf.readInt16LE(0).toString()); // 打印: 1280
let buf1 = buffer.alloc(2); let buf1 = buffer.alloc(2);
buf1.writeInt16BE(0x1234, 0); let result = buf1.writeInt16BE(0x1234, 0);
``` ```
### readInt32BE ### readInt32BE
...@@ -1316,7 +1316,7 @@ let buf = buffer.from([0, 0, 0, 5]); ...@@ -1316,7 +1316,7 @@ let buf = buffer.from([0, 0, 0, 5]);
console.log(buf.readInt32BE(0).toString()); // 打印: 5 console.log(buf.readInt32BE(0).toString()); // 打印: 5
let buf1 = buffer.alloc(4); let buf1 = buffer.alloc(4);
buf1.writeInt32BE(0x12345678, 0); let result = buf1.writeInt32BE(0x12345678, 0);
``` ```
### readInt32LE ### readInt32LE
...@@ -1356,7 +1356,7 @@ let buf = buffer.from([0, 0, 0, 5]); ...@@ -1356,7 +1356,7 @@ let buf = buffer.from([0, 0, 0, 5]);
console.log(buf.readInt32LE(0).toString()); // 打印: 83886080 console.log(buf.readInt32LE(0).toString()); // 打印: 83886080
let buf1 = buffer.alloc(4); let buf1 = buffer.alloc(4);
buf1.writeInt32BE(0x12345678, 0); let result = buf1.writeInt32BE(0x12345678, 0);
``` ```
### readIntBE ### readIntBE
...@@ -1399,7 +1399,7 @@ let num = buf.readIntBE(0, 1); ...@@ -1399,7 +1399,7 @@ let num = buf.readIntBE(0, 1);
console.log(num.toString()); // 97 console.log(num.toString()); // 97
let buf1 = buffer.allocUninitializedFromPool(6); let buf1 = buffer.allocUninitializedFromPool(6);
buf1.writeIntBE(0x123456789011, 0, 6); let result = buf1.writeIntBE(0x123456789011, 0, 6);
``` ```
...@@ -1442,7 +1442,7 @@ let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); ...@@ -1442,7 +1442,7 @@ let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
console.log(buf.readIntLE(0, 6).toString(16)); console.log(buf.readIntLE(0, 6).toString(16));
let buf1 = buffer.allocUninitializedFromPool(6); let buf1 = buffer.allocUninitializedFromPool(6);
buf1.writeIntLE(0x123456789011, 0, 6); let result = buf1.writeIntLE(0x123456789011, 0, 6);
``` ```
### readUInt8 ### readUInt8
...@@ -1484,7 +1484,7 @@ console.log(buf.readUInt8(0).toString()); ...@@ -1484,7 +1484,7 @@ console.log(buf.readUInt8(0).toString());
console.log(buf.readUInt8(1).toString()); console.log(buf.readUInt8(1).toString());
let buf1 = buffer.allocUninitializedFromPool(4); let buf1 = buffer.allocUninitializedFromPool(4);
buf1.writeUInt8(0x42); let result = buf1.writeUInt8(0x42);
``` ```
### readUInt16BE ### readUInt16BE
...@@ -1526,7 +1526,7 @@ console.log(buf.readUInt16BE(0).toString(16)); ...@@ -1526,7 +1526,7 @@ console.log(buf.readUInt16BE(0).toString(16));
console.log(buf.readUInt16BE(1).toString(16)); console.log(buf.readUInt16BE(1).toString(16));
let buf1 = buffer.allocUninitializedFromPool(4); let buf1 = buffer.allocUninitializedFromPool(4);
buf1.writeUInt16BE(0x1234, 0); let result = buf1.writeUInt16BE(0x1234, 0);
``` ```
### readUInt16LE ### readUInt16LE
...@@ -1568,7 +1568,7 @@ console.log(buf.readUInt16LE(0).toString(16)); ...@@ -1568,7 +1568,7 @@ console.log(buf.readUInt16LE(0).toString(16));
console.log(buf.readUInt16LE(1).toString(16)); console.log(buf.readUInt16LE(1).toString(16));
let buf1 = buffer.allocUninitializedFromPool(4); let buf1 = buffer.allocUninitializedFromPool(4);
buf1.writeUInt16LE(0x1234, 0); let result = buf1.writeUInt16LE(0x1234, 0);
``` ```
### readUInt32BE ### readUInt32BE
...@@ -1609,7 +1609,7 @@ let buf = buffer.from([0x12, 0x34, 0x56, 0x78]); ...@@ -1609,7 +1609,7 @@ let buf = buffer.from([0x12, 0x34, 0x56, 0x78]);
console.log(buf.readUInt32BE(0).toString(16)); console.log(buf.readUInt32BE(0).toString(16));
let buf1 = buffer.allocUninitializedFromPool(4); let buf1 = buffer.allocUninitializedFromPool(4);
buf1.writeUInt32BE(0x12345678, 0); let result = buf1.writeUInt32BE(0x12345678, 0);
``` ```
### readUInt32LE ### readUInt32LE
...@@ -1650,7 +1650,7 @@ let buf = buffer.from([0x12, 0x34, 0x56, 0x78]); ...@@ -1650,7 +1650,7 @@ let buf = buffer.from([0x12, 0x34, 0x56, 0x78]);
console.log(buf.readUInt32LE(0).toString(16)); console.log(buf.readUInt32LE(0).toString(16));
let buf1 = buffer.allocUninitializedFromPool(4); let buf1 = buffer.allocUninitializedFromPool(4);
buf1.writeUInt32LE(0x12345678, 0); let result = buf1.writeUInt32LE(0x12345678, 0);
``` ```
### readUIntBE ### readUIntBE
...@@ -1692,7 +1692,7 @@ let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); ...@@ -1692,7 +1692,7 @@ let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
console.log(buf.readUIntBE(0, 6).toString(16)); console.log(buf.readUIntBE(0, 6).toString(16));
let buf1 = buffer.allocUninitializedFromPool(4); let buf1 = buffer.allocUninitializedFromPool(4);
buf1.writeUIntBE(0x13141516, 0, 4); let result = buf1.writeUIntBE(0x13141516, 0, 4);
``` ```
### readUIntLE ### readUIntLE
...@@ -1734,7 +1734,7 @@ let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); ...@@ -1734,7 +1734,7 @@ let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
console.log(buf.readUIntLE(0, 6).toString(16)); console.log(buf.readUIntLE(0, 6).toString(16));
let buf1 = buffer.allocUninitializedFromPool(4); let buf1 = buffer.allocUninitializedFromPool(4);
buf1.writeUIntLE(0x13141516, 0, 4); let result = buf1.writeUIntLE(0x13141516, 0, 4);
``` ```
### subarray ### subarray
...@@ -2045,7 +2045,7 @@ writeBigInt64BE(value: bigint, offset?: number): number ...@@ -2045,7 +2045,7 @@ writeBigInt64BE(value: bigint, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(8); let buf = buffer.allocUninitializedFromPool(8);
buf.writeBigInt64BE(0x0102030405060708n, 0); let result = buf.writeBigInt64BE(0x0102030405060708n, 0);
``` ```
### writeBigInt64LE ### writeBigInt64LE
...@@ -2084,7 +2084,7 @@ writeBigInt64LE(value: bigint, offset?: number): number ...@@ -2084,7 +2084,7 @@ writeBigInt64LE(value: bigint, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(8); let buf = buffer.allocUninitializedFromPool(8);
buf.writeBigInt64LE(0x0102030405060708n, 0); let result = buf.writeBigInt64LE(0x0102030405060708n, 0);
``` ```
### writeBigUInt64BE ### writeBigUInt64BE
...@@ -2123,7 +2123,7 @@ writeBigUInt64BE(value: bigint, offset?: number): number ...@@ -2123,7 +2123,7 @@ writeBigUInt64BE(value: bigint, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(8); let buf = buffer.allocUninitializedFromPool(8);
buf.writeBigUInt64BE(0xdecafafecacefaden, 0); let result = buf.writeBigUInt64BE(0xdecafafecacefaden, 0);
``` ```
### writeBigUInt64LE ### writeBigUInt64LE
...@@ -2162,7 +2162,7 @@ writeBigUInt64LE(value: bigint, offset?: number): number ...@@ -2162,7 +2162,7 @@ writeBigUInt64LE(value: bigint, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(8); let buf = buffer.allocUninitializedFromPool(8);
buf.writeBigUInt64LE(0xdecafafecacefaden, 0); let result = buf.writeBigUInt64LE(0xdecafafecacefaden, 0);
``` ```
### writeDoubleBE ### writeDoubleBE
...@@ -2201,7 +2201,7 @@ writeDoubleBE(value: number, offset?: number): number ...@@ -2201,7 +2201,7 @@ writeDoubleBE(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(8); let buf = buffer.allocUninitializedFromPool(8);
buf.writeDoubleBE(123.456, 0); let result = buf.writeDoubleBE(123.456, 0);
``` ```
### writeDoubleLE ### writeDoubleLE
...@@ -2240,7 +2240,7 @@ writeDoubleLE(value: number, offset?: number): number ...@@ -2240,7 +2240,7 @@ writeDoubleLE(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(8); let buf = buffer.allocUninitializedFromPool(8);
buf.writeDoubleLE(123.456, 0); let result = buf.writeDoubleLE(123.456, 0);
``` ```
### writeFloatBE ### writeFloatBE
...@@ -2279,7 +2279,7 @@ writeFloatBE(value: number, offset?: number): number ...@@ -2279,7 +2279,7 @@ writeFloatBE(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(8); let buf = buffer.allocUninitializedFromPool(8);
buf.writeFloatBE(0xcafebabe, 0); let result = buf.writeFloatBE(0xcafebabe, 0);
``` ```
...@@ -2319,7 +2319,7 @@ writeFloatLE(value: number, offset?: number): number ...@@ -2319,7 +2319,7 @@ writeFloatLE(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(8); let buf = buffer.allocUninitializedFromPool(8);
buf.writeFloatLE(0xcafebabe, 0); let result = buf.writeFloatLE(0xcafebabe, 0);
``` ```
### writeInt8 ### writeInt8
...@@ -2358,8 +2358,8 @@ writeInt8(value: number, offset?: number): number ...@@ -2358,8 +2358,8 @@ writeInt8(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(2); let buf = buffer.allocUninitializedFromPool(2);
buf.writeInt8(2, 0); let result = buf.writeInt8(2, 0);
buf.writeInt8(-2, 1); let result1 = buf.writeInt8(-2, 1);
``` ```
...@@ -2399,7 +2399,7 @@ writeInt16BE(value: number, offset?: number): number ...@@ -2399,7 +2399,7 @@ writeInt16BE(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(2); let buf = buffer.allocUninitializedFromPool(2);
buf.writeInt16BE(0x0102, 0); let result = buf.writeInt16BE(0x0102, 0);
``` ```
...@@ -2439,7 +2439,7 @@ writeInt16LE(value: number, offset?: number): number ...@@ -2439,7 +2439,7 @@ writeInt16LE(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(2); let buf = buffer.allocUninitializedFromPool(2);
buf.writeInt16LE(0x0304, 0); let result = buf.writeInt16LE(0x0304, 0);
``` ```
### writeInt32BE ### writeInt32BE
...@@ -2478,7 +2478,7 @@ writeInt32BE(value: number, offset?: number): number ...@@ -2478,7 +2478,7 @@ writeInt32BE(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(4); let buf = buffer.allocUninitializedFromPool(4);
buf.writeInt32BE(0x01020304, 0); let result = buf.writeInt32BE(0x01020304, 0);
``` ```
...@@ -2518,7 +2518,7 @@ writeInt32LE(value: number, offset?: number): number ...@@ -2518,7 +2518,7 @@ writeInt32LE(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(4); let buf = buffer.allocUninitializedFromPool(4);
buf.writeInt32LE(0x05060708, 0); let result = buf.writeInt32LE(0x05060708, 0);
``` ```
### writeIntBE ### writeIntBE
...@@ -2558,7 +2558,7 @@ writeIntBE(value: number, offset: number, byteLength: number): number ...@@ -2558,7 +2558,7 @@ writeIntBE(value: number, offset: number, byteLength: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(6); let buf = buffer.allocUninitializedFromPool(6);
buf.writeIntBE(0x1234567890ab, 0, 6); let result = buf.writeIntBE(0x1234567890ab, 0, 6);
``` ```
...@@ -2599,7 +2599,7 @@ writeIntLE(value: number, offset: number, byteLength: number): number ...@@ -2599,7 +2599,7 @@ writeIntLE(value: number, offset: number, byteLength: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(6); let buf = buffer.allocUninitializedFromPool(6);
buf.writeIntLE(0x1234567890ab, 0, 6); let result = buf.writeIntLE(0x1234567890ab, 0, 6);
``` ```
### writeUInt8 ### writeUInt8
...@@ -2638,10 +2638,10 @@ writeUInt8(value: number, offset?: number): number ...@@ -2638,10 +2638,10 @@ writeUInt8(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(4); let buf = buffer.allocUninitializedFromPool(4);
buf.writeUInt8(0x3, 0); let result = buf.writeUInt8(0x3, 0);
buf.writeUInt8(0x4, 1); let result1 = buf.writeUInt8(0x4, 1);
buf.writeUInt8(0x23, 2); let result2 = buf.writeUInt8(0x23, 2);
buf.writeUInt8(0x42, 3); let result3 = buf.writeUInt8(0x42, 3);
``` ```
### writeUInt16BE ### writeUInt16BE
...@@ -2680,8 +2680,8 @@ writeUInt16BE(value: number, offset?: number): number ...@@ -2680,8 +2680,8 @@ writeUInt16BE(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(4); let buf = buffer.allocUninitializedFromPool(4);
buf.writeUInt16BE(0xdead, 0); let result = buf.writeUInt16BE(0xdead, 0);
buf.writeUInt16BE(0xbeef, 2); let result1 = buf.writeUInt16BE(0xbeef, 2);
``` ```
### writeUInt16LE ### writeUInt16LE
...@@ -2720,8 +2720,8 @@ writeUInt16LE(value: number, offset?: number): number ...@@ -2720,8 +2720,8 @@ writeUInt16LE(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(4); let buf = buffer.allocUninitializedFromPool(4);
buf.writeUInt16LE(0xdead, 0); let result = buf.writeUInt16LE(0xdead, 0);
buf.writeUInt16LE(0xbeef, 2); let result1 = buf.writeUInt16LE(0xbeef, 2);
``` ```
### writeUInt32BE ### writeUInt32BE
...@@ -2760,7 +2760,7 @@ writeUInt32BE(value: number, offset?: number): number ...@@ -2760,7 +2760,7 @@ writeUInt32BE(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(4); let buf = buffer.allocUninitializedFromPool(4);
buf.writeUInt32BE(0xfeedface, 0); let result = buf.writeUInt32BE(0xfeedface, 0);
``` ```
### writeUInt32LE ### writeUInt32LE
...@@ -2799,7 +2799,7 @@ writeUInt32LE(value: number, offset?: number): number ...@@ -2799,7 +2799,7 @@ writeUInt32LE(value: number, offset?: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(4); let buf = buffer.allocUninitializedFromPool(4);
buf.writeUInt32LE(0xfeedface, 0); let result = buf.writeUInt32LE(0xfeedface, 0);
``` ```
### writeUIntBE ### writeUIntBE
...@@ -2839,7 +2839,7 @@ writeUIntBE(value: number, offset: number, byteLength: number): number ...@@ -2839,7 +2839,7 @@ writeUIntBE(value: number, offset: number, byteLength: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(6); let buf = buffer.allocUninitializedFromPool(6);
buf.writeUIntBE(0x1234567890ab, 0, 6); let result = buf.writeUIntBE(0x1234567890ab, 0, 6);
``` ```
### writeUIntLE ### writeUIntLE
...@@ -2879,7 +2879,7 @@ writeUIntLE(value: number, offset: number, byteLength: number): number ...@@ -2879,7 +2879,7 @@ writeUIntLE(value: number, offset: number, byteLength: number): number
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(6); let buf = buffer.allocUninitializedFromPool(6);
buf.writeUIntLE(0x1234567890ab, 0, 6); let result = buf.writeUIntLE(0x1234567890ab, 0, 6);
``` ```
## Blob ## Blob
......
...@@ -9,7 +9,7 @@ Deque和[Queue](js-apis-queue.md)相比,Queue的特点是先进先出,只能 ...@@ -9,7 +9,7 @@ Deque和[Queue](js-apis-queue.md)相比,Queue的特点是先进先出,只能
**推荐使用场景:** 需要频繁在集合两端进行增删元素的操作时,推荐使用Deque。 **推荐使用场景:** 需要频繁在集合两端进行增删元素的操作时,推荐使用Deque。
文档中存在泛型的使用,涉及以下泛型标记符:<br> 文档中存在泛型的使用,涉及以下泛型标记符:<br>
- T:Type, - T:Type
> **说明:** > **说明:**
> >
...@@ -156,9 +156,8 @@ has(element: T): boolean ...@@ -156,9 +156,8 @@ has(element: T): boolean
```ts ```ts
let deque = new Deque(); let deque = new Deque();
let result = deque.has("squirrel");
deque.insertFront("squirrel"); deque.insertFront("squirrel");
let result1 = deque.has("squirrel"); let result = deque.has("squirrel");
``` ```
### popFirst ### popFirst
......
...@@ -119,9 +119,8 @@ hasKey(key: K): boolean ...@@ -119,9 +119,8 @@ hasKey(key: K): boolean
```ts ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
let result = hashMap.hasKey("squirrel");
hashMap.set("squirrel", 123); hashMap.set("squirrel", 123);
let result1 = hashMap.hasKey("squirrel"); let result = hashMap.hasKey("squirrel");
``` ```
...@@ -157,9 +156,8 @@ hasValue(value: V): boolean ...@@ -157,9 +156,8 @@ hasValue(value: V): boolean
```ts ```ts
let hashMap = new HashMap(); let hashMap = new HashMap();
let result = hashMap.hasValue(123);
hashMap.set("squirrel", 123); hashMap.set("squirrel", 123);
let result1 = hashMap.hasValue(123); let result = hashMap.hasValue(123);
``` ```
...@@ -230,6 +228,7 @@ let hashMap = new HashMap(); ...@@ -230,6 +228,7 @@ let hashMap = new HashMap();
hashMap.set("squirrel", 123); hashMap.set("squirrel", 123);
hashMap.set("sparrow", 356); hashMap.set("sparrow", 356);
let newHashMap = new HashMap(); let newHashMap = new HashMap();
newHashMap.set("newMap", 99);
hashMap.setAll(newHashMap); hashMap.setAll(newHashMap);
``` ```
......
# @ohos.util.HashSet (非线性容器HashSet) # @ohos.util.HashSet (非线性容器HashSet)
> **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
HashSet基于[HashMap](js-apis-hashmap.md)实现。在HashSet中,只对value对象进行处理。 HashSet基于[HashMap](js-apis-hashmap.md)实现。在HashSet中,只对value对象进行处理。
HashSet和[TreeSet](js-apis-treeset.md)相比,HashSet中的数据无序存放,即存放元素的顺序和取出的顺序不一致,而TreeSet是有序存放。它们集合中的元素都不允许重复,但HashSet允许放入null值,TreeSet不允许。 HashSet和[TreeSet](js-apis-treeset.md)相比,HashSet中的数据无序存放,即存放元素的顺序和取出的顺序不一致,而TreeSet是有序存放。它们集合中的元素都不允许重复,但HashSet允许放入null值,TreeSet不允许。
**推荐使用场景:** 可以利用HashSet不重复的特性,当需要不重复的集合或需要去重某个集合的时候使用。 **推荐使用场景:** 可以利用HashSet不重复的特性,当需要不重复的集合或需要去重某个集合的时候使用。
文档中存在泛型的使用,涉及以下泛型标记符:<br> 文档中存在泛型的使用,涉及以下泛型标记符:<br>
- T: Type, 类 - T:Type,类
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
...@@ -125,9 +127,8 @@ has(value: T): boolean ...@@ -125,9 +127,8 @@ has(value: T): boolean
```ts ```ts
let hashSet = new HashSet(); let hashSet = new HashSet();
let result = hashSet.has("squirrel");
hashSet.add("squirrel"); hashSet.add("squirrel");
let result1 = hashSet.has("squirrel"); let result = hashSet.has("squirrel");
``` ```
......
# @ohos.util.LightWeightMap (非线性容器LightWeightMap) # @ohos.util.LightWeightMap (非线性容器LightWeightMap)
> **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
LightWeightMap可用于存储具有关联关系的key-value键值对集合,存储元素中key值唯一,每个key对应一个value。 LightWeightMap可用于存储具有关联关系的key-value键值对集合,存储元素中key值唯一,每个key对应一个value。
LightWeightMap依据泛型定义,采用轻量级结构,初始默认容量大小为8,每次扩容大小为原始容量的两倍。 LightWeightMap依据泛型定义,采用轻量级结构,初始默认容量大小为8,每次扩容大小为原始容量的两倍。
...@@ -13,9 +10,14 @@ LightWeightMap和[HashMap](js-apis-hashmap.md)都是用来存储键值对的集 ...@@ -13,9 +10,14 @@ LightWeightMap和[HashMap](js-apis-hashmap.md)都是用来存储键值对的集
**推荐使用场景:** 当需要存取key-value键值对时,推荐使用占用内存更小的LightWeightMap。 **推荐使用场景:** 当需要存取key-value键值对时,推荐使用占用内存更小的LightWeightMap。
文档中存在泛型的使用,涉及以下泛型标记符:<br> 文档中存在泛型的使用,涉及以下泛型标记符:<br>
- K: Key, 键<br> - K:Key,键<br>
- V: Value, 值 - V:Value,值
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
...@@ -197,9 +199,8 @@ hasValue(value: V): boolean ...@@ -197,9 +199,8 @@ hasValue(value: V): boolean
```ts ```ts
let lightWeightMap = new LightWeightMap(); let lightWeightMap = new LightWeightMap();
let result = lightWeightMap.hasValue(123);
lightWeightMap.set("squirrel", 123); lightWeightMap.set("squirrel", 123);
let result1 = lightWeightMap.hasValue(123); let result = lightWeightMap.hasValue(123);
``` ```
......
# @ohos.util.LightWeightSet (非线性容器LightWeightSet) # @ohos.util.LightWeightSet (非线性容器LightWeightSet)
> **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
LightWeightSet可用于存储一系列值的集合,存储元素中value值唯一。 LightWeightSet可用于存储一系列值的集合,存储元素中value值唯一。
LightWeightSet依据泛型定义,采用轻量级结构,初始默认容量大小为8,每次扩容大小为原始容量的两倍。 LightWeightSet依据泛型定义,采用轻量级结构,初始默认容量大小为8,每次扩容大小为原始容量的两倍。
...@@ -13,8 +10,13 @@ LightWeightSet和[HashSet](js-apis-hashset.md)都是用来存储键值的集合 ...@@ -13,8 +10,13 @@ LightWeightSet和[HashSet](js-apis-hashset.md)都是用来存储键值的集合
**推荐使用场景:** 当需要存取某个集合或是对某个集合去重时,推荐使用占用内存更小的LightWeightSet。 **推荐使用场景:** 当需要存取某个集合或是对某个集合去重时,推荐使用占用内存更小的LightWeightSet。
文档中存在泛型的使用,涉及以下泛型标记符:<br> 文档中存在泛型的使用,涉及以下泛型标记符:<br>
- T: Type, 类 - T:Type,类
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
...@@ -227,9 +229,8 @@ has(key: T): boolean ...@@ -227,9 +229,8 @@ has(key: T): boolean
```ts ```ts
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
let result = lightWeightSet.has(123);
lightWeightSet.add(123); lightWeightSet.add(123);
result = lightWeightSet.has(123); let result = lightWeightSet.has(123);
``` ```
...@@ -267,7 +268,7 @@ equal(obj: Object): boolean ...@@ -267,7 +268,7 @@ equal(obj: Object): boolean
let lightWeightSet = new LightWeightSet(); let lightWeightSet = new LightWeightSet();
lightWeightSet.add("squirrel"); lightWeightSet.add("squirrel");
lightWeightSet.add("sparrow"); lightWeightSet.add("sparrow");
let obj = ["squirrel", "sparrow"]; let obj = ["sparrow", "squirrel"];
let result = lightWeightSet.equal(obj); let result = lightWeightSet.equal(obj);
``` ```
......
...@@ -198,7 +198,6 @@ has(element: T): boolean ...@@ -198,7 +198,6 @@ has(element: T): boolean
```ts ```ts
let linkedList = new LinkedList(); let linkedList = new LinkedList();
let result1 = linkedList.has("squirrel");
linkedList.add("squirrel"); linkedList.add("squirrel");
let result = linkedList.has("squirrel"); let result = linkedList.has("squirrel");
``` ```
...@@ -802,7 +801,7 @@ linkedList.add(2); ...@@ -802,7 +801,7 @@ linkedList.add(2);
linkedList.add(4); linkedList.add(4);
linkedList.add(5); linkedList.add(5);
linkedList.add(4); linkedList.add(4);
linkedList.getLast(); let result = linkedList.getLast();
``` ```
### [Symbol.iterator] ### [Symbol.iterator]
......
...@@ -7,12 +7,13 @@ List和[LinkedList](js-apis-linkedlist.md)相比,LinkedList是双向链表, ...@@ -7,12 +7,13 @@ List和[LinkedList](js-apis-linkedlist.md)相比,LinkedList是双向链表,
**推荐使用场景:** 当需要频繁的插入删除时,推荐使用List高效操作。 **推荐使用场景:** 当需要频繁的插入删除时,推荐使用List高效操作。
文档中存在泛型的使用,涉及以下泛型标记符:<br> 文档中存在泛型的使用,涉及以下泛型标记符:<br>
- T:Type, - T:Type
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
...@@ -160,9 +161,8 @@ has(element: T): boolean ...@@ -160,9 +161,8 @@ has(element: T): boolean
```ts ```ts
let list = new List(); let list = new List();
let result = list.has("squirrel");
list.add("squirrel"); list.add("squirrel");
let result1 = list.has("squirrel"); let result = list.has("squirrel");
``` ```
### get ### get
...@@ -288,7 +288,6 @@ list.add(2); ...@@ -288,7 +288,6 @@ list.add(2);
list.add(1); list.add(1);
list.add(2); list.add(2);
list.add(4); list.add(4);
list.getIndexOf(2);
let result = list.getIndexOf(2); let result = list.getIndexOf(2);
``` ```
...@@ -327,14 +326,11 @@ let list = new List(); ...@@ -327,14 +326,11 @@ let list = new List();
list.add(2); list.add(2);
list.add(4); list.add(4);
list.add(5); list.add(5);
list.add(2); let obj = new List();
let obj1 = new List(); obj.add(2);
obj1.add(2); obj.add(4);
obj1.add(4); obj.add(5);
obj1.add(5); let result = list.equal(obj);
list.equal(obj1);
let obj2 = {name : "Dylon", age : "13"};
let result = list.equal(obj2);
``` ```
### removeByIndex ### removeByIndex
...@@ -457,11 +453,9 @@ list.add(2); ...@@ -457,11 +453,9 @@ list.add(2);
list.add(4); list.add(4);
list.add(5); list.add(5);
list.add(4); list.add(4);
list.replaceAllElements((value: number, index: number) => { list.replaceAllElements((value) => {
return value = 2 * value; // 用户操作逻辑根据实际场景进行添加。
}); return value;
list.replaceAllElements((value: number, index: number) => {
return value = value - 2;
}); });
``` ```
...@@ -589,9 +583,7 @@ list.add(2); ...@@ -589,9 +583,7 @@ list.add(2);
list.add(4); list.add(4);
list.add(5); list.add(5);
list.add(4); list.add(4);
let result = list.getSubList(2, 4); let result = list.getSubList(1, 3);
let result1 = list.getSubList(4, 3);
let result2 = list.getSubList(2, 6);
``` ```
### clear ### clear
...@@ -659,7 +651,7 @@ list.add(2); ...@@ -659,7 +651,7 @@ list.add(2);
list.add(4); list.add(4);
list.add(5); list.add(5);
list.add(4); list.add(4);
list.set(2, "b"); let result = list.set(2, "b");
``` ```
### convertToArray ### convertToArray
......
# @ohos.util.PlainArray (非线性容器PlainArray) # @ohos.util.PlainArray (非线性容器PlainArray)
> **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
PlainArray可用于存储具有关联关系的key-value键值对集合,存储元素中key值唯一,key值类型为number类型,每个key对应一个value。 PlainArray可用于存储具有关联关系的key-value键值对集合,存储元素中key值唯一,key值类型为number类型,每个key对应一个value。
PlainArray依据泛型定义,采用轻量级结构,集合中key值的查找依赖于二分查找算法,然后映射到其他数组中的value值。 PlainArray依据泛型定义,采用轻量级结构,集合中key值的查找依赖于二分查找算法,然后映射到其他数组中的value值。
...@@ -11,8 +8,13 @@ PlainArray和[LightWeightMap](js-apis-lightweightmap.md)都是用来存储键值 ...@@ -11,8 +8,13 @@ PlainArray和[LightWeightMap](js-apis-lightweightmap.md)都是用来存储键值
**推荐使用场景:** 当需要存储key值为number类型的键值对时,可以使用PlainArray。 **推荐使用场景:** 当需要存储key值为number类型的键值对时,可以使用PlainArray。
文档中存在泛型的使用,涉及以下泛型标记符:<br> 文档中存在泛型的使用,涉及以下泛型标记符:<br>
- T: Type, 类 - T:Type,类
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
...@@ -21,7 +23,6 @@ import PlainArray from '@ohos.util.PlainArray'; ...@@ -21,7 +23,6 @@ import PlainArray from '@ohos.util.PlainArray';
``` ```
## PlainArray ## PlainArray
### 属性 ### 属性
...@@ -118,9 +119,8 @@ has(key: number): boolean ...@@ -118,9 +119,8 @@ has(key: number): boolean
```ts ```ts
let plainArray = new PlainArray(); let plainArray = new PlainArray();
plainArray.has(1);
plainArray.add(1, "squirrel"); plainArray.add(1, "squirrel");
let result1 = plainArray.has(1); let result = plainArray.has(1);
``` ```
......
# @ohos.util.Queue (线性容器Queue) # @ohos.util.Queue (线性容器Queue)
> **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
Queue的特点是先进先出,在尾部增加元素,在头部删除元素。根据循环队列的数据结构实现。 Queue的特点是先进先出,在尾部增加元素,在头部删除元素。根据循环队列的数据结构实现。
Queue和[Deque](js-apis-deque.md)相比,Queue只能在一端删除一端增加,Deque可以两端增删。 Queue和[Deque](js-apis-deque.md)相比,Queue只能在一端删除一端增加,Deque可以两端增删。
**推荐使用场景:** 一般符合先进先出的场景可以使用Queue。 **推荐使用场景:** 一般符合先进先出的场景可以使用Queue。
文档中存在泛型的使用,涉及以下泛型标记符:<br> 文档中存在泛型的使用,涉及以下泛型标记符:<br>
- T: Type, 类 - T:Type,类
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
......
# @ohos.util.Stack (线性容器Stack) # @ohos.util.Stack (线性容器Stack)
> **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
Stack基于数组的数据结构实现,特点是先进后出,只能在一端进行数据的插入和删除。 Stack基于数组的数据结构实现,特点是先进后出,只能在一端进行数据的插入和删除。
Stack和[Queue](js-apis-queue.md)相比,Queue基于循环队列实现,只能在一端删除,另一端插入,而Stack都在一端操作。 Stack和[Queue](js-apis-queue.md)相比,Queue基于循环队列实现,只能在一端删除,另一端插入,而Stack都在一端操作。
**推荐使用场景:** 一般符合先进后出的场景可以使用Stack。 **推荐使用场景:** 一般符合先进后出的场景可以使用Stack。
文档中存在泛型的使用,涉及以下泛型标记符:<br> 文档中存在泛型的使用,涉及以下泛型标记符:<br>
- T: Type, 类 - T:Type,类
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
......
...@@ -8,16 +8,17 @@ TreeMap和[HashMap](js-apis-treemap.md)相比,HashMap依据键的hashCode存 ...@@ -8,16 +8,17 @@ TreeMap和[HashMap](js-apis-treemap.md)相比,HashMap依据键的hashCode存
**推荐使用场景:** 一般需要存储有序键值对的场景,可以使用TreeMap。 **推荐使用场景:** 一般需要存储有序键值对的场景,可以使用TreeMap。
文档中存在泛型的使用,涉及以下泛型标记符: 文档中存在泛型的使用,涉及以下泛型标记符
- K: Key, - K:Key,
- V: Value, - V:Value,
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
...@@ -126,9 +127,8 @@ hasKey(key: K): boolean ...@@ -126,9 +127,8 @@ hasKey(key: K): boolean
```ts ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
let result = treeMap.hasKey("squirrel");
treeMap.set("squirrel", 123); treeMap.set("squirrel", 123);
let result1 = treeMap.hasKey("squirrel"); let result = treeMap.hasKey("squirrel");
``` ```
...@@ -164,9 +164,8 @@ hasValue(value: V): boolean ...@@ -164,9 +164,8 @@ hasValue(value: V): boolean
```ts ```ts
let treeMap = new TreeMap(); let treeMap = new TreeMap();
let result = treeMap.hasValue(123);
treeMap.set("squirrel", 123); treeMap.set("squirrel", 123);
let result1 = treeMap.hasValue(123); let result = treeMap.hasValue(123);
``` ```
...@@ -304,7 +303,7 @@ let map = new TreeMap(); ...@@ -304,7 +303,7 @@ let map = new TreeMap();
map.set("demo", 12); map.set("demo", 12);
map.setAll(treeMap); // 将treeMap中的所有元素添加到map中 map.setAll(treeMap); // 将treeMap中的所有元素添加到map中
map.forEach((value, key) => { map.forEach((value, key) => {
console.log("test" + value, key); // 打印结果 12 demo、356 sparrow、123 squirrel console.log("value" + value, "key" + key); // 打印结果 12 demo、356 sparrow、123 squirrel
}) })
``` ```
...@@ -380,7 +379,7 @@ remove(key: K): V ...@@ -380,7 +379,7 @@ remove(key: K): V
let treeMap = new TreeMap(); let treeMap = new TreeMap();
treeMap.set("squirrel", 123); treeMap.set("squirrel", 123);
treeMap.set("sparrow", 356); treeMap.set("sparrow", 356);
treeMap.remove("sparrow"); let result = treeMap.remove("sparrow");
``` ```
......
...@@ -6,14 +6,15 @@ TreeSet和[HashSet](js-apis-hashset.md)相比,HashSet中的数据无序存放 ...@@ -6,14 +6,15 @@ TreeSet和[HashSet](js-apis-hashset.md)相比,HashSet中的数据无序存放
**推荐使用场景:** 一般需要存储有序集合的场景,可以使用TreeSet。 **推荐使用场景:** 一般需要存储有序集合的场景,可以使用TreeSet。
文档中存在泛型的使用,涉及以下泛型标记符: 文档中存在泛型的使用,涉及以下泛型标记符:
- T: Type, - T:Type,
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
...@@ -122,9 +123,8 @@ has(value: T): boolean ...@@ -122,9 +123,8 @@ has(value: T): boolean
```ts ```ts
let treeSet = new TreeSet(); let treeSet = new TreeSet();
treeSet.has(123);
treeSet.add(123); treeSet.add(123);
let result1 = treeSet.has(123); let result = treeSet.has(123);
``` ```
......
...@@ -145,7 +145,7 @@ toString(): string ...@@ -145,7 +145,7 @@ toString(): string
```js ```js
const result = new uri.URI('https://username:password@host:8080/directory/file?query=pppppp#qwer=da'); const result = new uri.URI('https://username:password@host:8080/directory/file?query=pppppp#qwer=da');
result.toString() let result1 = result.toString();
``` ```
...@@ -205,7 +205,7 @@ equalsTo(other: URI): boolean ...@@ -205,7 +205,7 @@ equalsTo(other: URI): boolean
```js ```js
const uriInstance = new uri.URI('https://username:password@host:8080/directory/file?query=pppppp#qwer=da'); const uriInstance = new uri.URI('https://username:password@host:8080/directory/file?query=pppppp#qwer=da');
const uriInstance1 = new uri.URI('https://username:password@host:8080/directory/file?query=pppppp#qwer=da'); const uriInstance1 = new uri.URI('https://username:password@host:8080/directory/file?query=pppppp#qwer=da');
uriInstance.equalsTo(uriInstance1); let result = uriInstance.equalsTo(uriInstance1);
``` ```
### checkIsAbsolute ### checkIsAbsolute
......
...@@ -225,7 +225,7 @@ has(name: string): boolean ...@@ -225,7 +225,7 @@ has(name: string): boolean
```js ```js
let urlObject = Url.URL.parseURL('https://developer.exampleUrl/?fod=1&bard=2'); let urlObject = Url.URL.parseURL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new Url.URLParams(urlObject.search.slice(1)); let paramsObject = new Url.URLParams(urlObject.search.slice(1));
paramsObject.has('bard') === true; let result = paramsObject.has('bard');
``` ```
...@@ -336,7 +336,7 @@ for (var value of searchParams.values()) { ...@@ -336,7 +336,7 @@ for (var value of searchParams.values()) {
```js ```js
const paramsObject = new Url.URLParams('fod=bay&edg=bap'); const paramsObject = new Url.URLParams('fod=bay&edg=bap');
for (const [name, value] of paramsObject) { for (const [name, value] of paramsObject[Symbol.iterator]()) {
console.log(name, value); console.log(name, value);
} }
``` ```
...@@ -460,7 +460,7 @@ URL静态成员函数。 ...@@ -460,7 +460,7 @@ URL静态成员函数。
```js ```js
let mm = 'https://username:password@host:8080'; let mm = 'https://username:password@host:8080';
let url = Url.URL.parseURL(mm); let url = Url.URL.parseURL(mm);
url.toString(); // Output 'https://username:password@host:8080/'; let result = url.toString(); // Output 'https://username:password@host:8080/'
``` ```
### tostring ### tostring
...@@ -481,7 +481,7 @@ toString(): string ...@@ -481,7 +481,7 @@ toString(): string
```js ```js
const url = Url.URL.parseURL('https://username:password@host:8080/directory/file?query=pppppp#qwer=da'); const url = Url.URL.parseURL('https://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toString(); let result = url.toString();
``` ```
### toJSON ### toJSON
...@@ -501,7 +501,7 @@ toJSON(): string ...@@ -501,7 +501,7 @@ toJSON(): string
**示例:** **示例:**
```js ```js
const url = Url.URL.parseURL('https://username:password@host:8080/directory/file?query=pppppp#qwer=da'); const url = Url.URL.parseURL('https://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toJSON(); let result = url.toJSON();
``` ```
## URLSearchParams<sup>(deprecated)</sup> ## URLSearchParams<sup>(deprecated)</sup>
......
...@@ -1119,7 +1119,7 @@ updateCapacity(newCapacity: number): void ...@@ -1119,7 +1119,7 @@ updateCapacity(newCapacity: number): void
```js ```js
let pro = new util.LRUCache(); let pro = new util.LRUCache();
let result = pro.updateCapacity(100); pro.updateCapacity(100);
``` ```
...@@ -1954,7 +1954,7 @@ let tempLower = new Temperature(30); ...@@ -1954,7 +1954,7 @@ let tempLower = new Temperature(30);
let tempUpper = new Temperature(40); let tempUpper = new Temperature(40);
let tempMiDF = new Temperature(35); let tempMiDF = new Temperature(35);
let range = new util.ScopeHelper(tempLower, tempUpper); let range = new util.ScopeHelper(tempLower, tempUpper);
range.contains(tempMiDF); let result = range.contains(tempMiDF);
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册