跳转至

@ohos.util.TreeSet

@ohos.util.TreeSet.remove

📖 官方API文档

⌨ 测试用例 1: 测试TreeSet容器remove接口

function test_remove(loopCount: number) {
  let treeset = new TreeSet<number>();
  for (let i = 0; i < 500000; i++) {
    treeset.add(i);
  }
  const startTime = new Date();
  for (let i = 0; i < loopCount; i++) {
    treeset.remove(i);
  }
  const endTime = new Date();
  const executionTime = endTime.getTime() - startTime.getTime();
  const averageTime = executionTime / loopCount;
  console.log(`!${test_id}: ${averageTime} ms`);
}
🕹 测试结果

测试用例 测试平台 运行时间
测试用例 1 Huawei Phone 0.000667 ms

@ohos.util.TreeSet.has

📖 官方API文档

⌨ 测试用例 1: 测试TreeSet容器has接口

function test_has(loopCount: number) {
  let treeset = new TreeSet<number>();
  for (let i = 0; i < 500000; i++) {
    treeset.add(i);
  }
  const startTime = new Date();
  for (let i = 0; i < loopCount; i++) {
    treeset.has(500000);
  }
  const endTime = new Date();
  const executionTime = endTime.getTime() - startTime.getTime();
  const averageTime = executionTime / loopCount;
  console.log(`!${test_id}: ${averageTime} ms`);
}
🕹 测试结果

测试用例 测试平台 运行时间
测试用例 1 Huawei Phone 0.000000 ms

@ohos.util.TreeSet.add

📖 官方API文档

⌨ 测试用例 1: 测试TreeSet容器add接口

function test_add(loopCount: number) {
  let treeset = new TreeSet<number>();
  const startTime = new Date();
  for (let i = 0; i < loopCount; i++) {
    treeset.add(i);
  }
  const endTime = new Date();
  const executionTime = endTime.getTime() - startTime.getTime();
  const averageTime = executionTime / loopCount;
  console.log(`!${test_id}: ${averageTime} ms`);
}
🕹 测试结果

测试用例 测试平台 运行时间
测试用例 1 Huawei Phone 0.000540 ms