• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.util.LightWeightSet (非线性容器LightWeightSet)
2<!--Kit: ArkTS-->
3<!--Subsystem: CommonLibrary-->
4<!--Owner: @xliu-huanwei; @shilei123; @huanghello-->
5<!--Designer: @yuanyao14-->
6<!--Tester: @kirl75; @zsw_zhushiwei-->
7<!--Adviser: @ge-yafang-->
8
9LightWeightSet可用于存储一系列值的集合,存储元素中value值唯一。
10
11LightWeightSet依据泛型定义,采用轻量级结构,初始默认容量大小为8,每次扩容大小为原始容量的两倍。
12
13集合中value值的查找依赖于hash算法,通过一个数组存储hash值,然后映射到其他数组中的value值。
14
15LightWeightSet和[HashSet](js-apis-hashset.md)都是用来存储键值的集合,但LightWeightSet的占用内存更小。
16
17**推荐使用场景:** 当需要存取某个集合或是对某个集合去重时,推荐使用占用内存更小的LightWeightSet。
18
19文档中使用了泛型,涉及以下泛型标记符:
20- T:Type,类
21
22> **说明:**
23>
24> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
25>
26> 容器类使用静态语言实现,限制了存储位置和属性,不支持自定义属性和方法。
27
28
29## 导入模块
30
31```ts
32import { LightWeightSet } from '@kit.ArkTS';
33```
34
35## LightWeightSet
36
37### 属性
38
39**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
40
41**系统能力:** SystemCapability.Utils.Lang
42
43| 名称 | 类型 | 只读 | 可选 | 说明 |
44| -------- | -------- | -------- | -------- | -------- |
45| length | number | 是 | 否 | LightWeightSet的元素个数。 |
46
47
48### constructor
49
50constructor()
51
52LightWeightSet的构造函数。
53
54**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
55
56**系统能力:** SystemCapability.Utils.Lang
57
58**错误码:**
59
60以下错误码的详细介绍请参见[语言基础类库错误码](errorcode-utils.md)。
61
62| 错误码ID | 错误信息 |
63| -------- | -------- |
64| 10200012 | The LightWeightSet's constructor cannot be directly invoked. |
65
66**示例:**
67
68```ts
69let lightWeightSet = new LightWeightSet<number | string>();
70```
71
72### isEmpty
73
74isEmpty(): boolean
75
76判断容器是否为空。
77
78**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
79
80**系统能力:** SystemCapability.Utils.Lang
81
82**返回值:**
83
84| 类型 | 说明 |
85| -------- | -------- |
86| boolean | 为空返回true,不为空返回false。 |
87
88**错误码:**
89
90以下错误码的详细介绍请参见[语言基础类库错误码](errorcode-utils.md)。
91
92| 错误码ID | 错误信息 |
93| -------- | -------- |
94| 10200011 | The isEmpty method cannot be bound. |
95
96**示例:**
97
98```ts
99const lightWeightSet = new LightWeightSet<number>();
100let result = lightWeightSet.isEmpty();
101console.info("result:", result);  // result: true
102```
103
104### add
105
106add(obj: T): boolean
107
108向容器中添加数据。
109
110**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
111
112**系统能力:** SystemCapability.Utils.Lang
113
114**参数:**
115
116| 参数名 | 类型 | 必填 | 说明 |
117| -------- | -------- | -------- | -------- |
118| obj | T | 是 | 添加的成员数据。 |
119
120**返回值:**
121
122| 类型 | 说明 |
123| -------- | -------- |
124| boolean | 成功添加元素返回true,否则返回false。 |
125
126**错误码:**
127
128以下错误码的详细介绍请参见[语言基础类库错误码](errorcode-utils.md)。
129
130| 错误码ID | 错误信息 |
131| -------- | -------- |
132| 10200011 | The add method cannot be bound. |
133
134**示例:**
135
136```ts
137let lightWeightSet = new LightWeightSet<string>();
138let result = lightWeightSet.add("squirrel");
139console.info("result:", result);  // result: true
140```
141
142
143### addAll
144
145addAll(set: LightWeightSet&lt;T&gt;): boolean
146
147将另一个容器的所有元素组添加到当前容器。
148
149**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
150
151**系统能力:** SystemCapability.Utils.Lang
152
153**参数:**
154
155| 参数名 | 类型 | 必填 | 说明 |
156| -------- | -------- | -------- | -------- |
157| set | LightWeightSet&lt;T&gt; | 是 | 提供添加元素的LightWeightSet。 |
158
159**返回值:**
160
161| 类型 | 说明 |
162| -------- | -------- |
163| boolean | 成功添加元素返回true,否则返回false。 |
164
165**错误码:**
166
167以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[语言基础类库错误码](errorcode-utils.md)。
168
169| 错误码ID | 错误信息 |
170| -------- | -------- |
171| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
172| 10200011 | The addAll method cannot be bound. |
173
174**示例:**
175
176```ts
177let lightWeightSet = new LightWeightSet<string>();
178lightWeightSet.add("squirrel");
179lightWeightSet.add("sparrow");
180let set = new LightWeightSet<string>();
181set.add("gull");
182lightWeightSet.addAll(set);
183let result = lightWeightSet.has("gull");
184console.info("result:", result);  // result: true
185```
186
187
188### hasAll
189
190hasAll(set: LightWeightSet&lt;T&gt;): boolean
191
192判断容器中是否包含指定set中的所有元素。
193
194**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
195
196**系统能力:** SystemCapability.Utils.Lang
197
198**参数:**
199
200| 参数名 | 类型 | 必填 | 说明 |
201| -------- | -------- | -------- | -------- |
202| set | LightWeightSet&lt;T&gt; | 是 | 比较对象。 |
203
204**返回值:**
205
206| 类型 | 说明 |
207| -------- | -------- |
208| boolean | 包含所有元素时返回true,否则返回false。 |
209
210**错误码:**
211
212以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[语言基础类库错误码](errorcode-utils.md)。
213
214| 错误码ID | 错误信息 |
215| -------- | -------- |
216| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
217| 10200011 | The hasAll method cannot be bound. |
218
219**示例:**
220
221```ts
222let lightWeightSet = new LightWeightSet<string>();
223lightWeightSet.add("squirrel");
224lightWeightSet.add("sparrow");
225let set = new LightWeightSet<string>();
226set.add("sparrow");
227let result = lightWeightSet.hasAll(set);
228console.info("result:", result);  // result: true
229```
230
231
232### has
233
234has(key: T): boolean
235
236判断容器中是否包含指定的key。
237
238**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
239
240**系统能力:** SystemCapability.Utils.Lang
241
242**参数:**
243
244| 参数名 | 类型 | 必填 | 说明 |
245| -------- | -------- | -------- | -------- |
246| key | T | 是 | 指定key |
247
248**返回值:**
249
250| 类型 | 说明 |
251| -------- | -------- |
252| boolean | 包含指定key时返回true,否则返回false。 |
253
254**错误码:**
255
256以下错误码的详细介绍请参见[语言基础类库错误码](errorcode-utils.md)。
257
258| 错误码ID | 错误信息 |
259| -------- | -------- |
260| 10200011 | The has method cannot be bound. |
261
262**示例:**
263
264```ts
265let lightWeightSet = new LightWeightSet<number>();
266lightWeightSet.add(123);
267let result = lightWeightSet.has(123);
268console.info("result:", result);  // result: true
269```
270
271
272### increaseCapacityTo
273
274increaseCapacityTo(minimumCapacity: number): void
275
276将当前LightWeightSet扩容至指定容量。如果传入的容量值大于或等于当前LightWeightSet中的元素个数,将容量变更为新容量,小于则不会变更。
277
278**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
279
280**系统能力:** SystemCapability.Utils.Lang
281
282**参数:**
283
284| 参数名 | 类型 | 必填 | 说明 |
285| -------- | -------- | -------- | -------- |
286| minimumCapacity | number | 是 | 需要容纳的元素数量。 |
287
288**错误码:**
289
290以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[语言基础类库错误码](errorcode-utils.md)。
291
292| 错误码ID | 错误信息 |
293| -------- | -------- |
294| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
295| 10200001 | The value of minimumCapacity is out of range. |
296| 10200011 | The increaseCapacityTo method cannot be bound. |
297
298**示例:**
299
300```ts
301let lightWeightSet = new LightWeightSet<string>();
302lightWeightSet.increaseCapacityTo(10);
303```
304
305
306### getIndexOf
307
308getIndexOf(key: T): number
309
310获取指定key所对应的下标。
311
312**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
313
314**系统能力:** SystemCapability.Utils.Lang
315
316**参数:**
317
318| 参数名 | 类型 | 必填 | 说明 |
319| -------- | -------- | -------- | -------- |
320| key | T | 是 | 查找的指定key。 |
321
322**返回值:**
323
324| 类型 | 说明 |
325| -------- | -------- |
326| number | 在lightWeightSet中指定数据的下标。若lightWeightSet中没有要查找的元素,则返回一个负值。表示目标哈希值应该插入的位置,插入位置是从1开始计数的,负号表示这是一个插入位置而不是索引。 |
327
328**错误码:**
329
330以下错误码的详细介绍请参见[语言基础类库错误码](errorcode-utils.md)。
331
332| 错误码ID | 错误信息 |
333| -------- | -------- |
334| 10200011 | The getIndexOf method cannot be bound. |
335
336**示例:**
337
338```ts
339let lightWeightSet = new LightWeightSet<string>();
340lightWeightSet.add("squirrel");
341lightWeightSet.add("sparrow");
342let result = lightWeightSet.getIndexOf("sparrow");
343console.info("result:", result);  // result: 0
344```
345
346
347### remove
348
349remove(key: T): T
350
351删除并返回指定key对应的元素。
352
353**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
354
355**系统能力:** SystemCapability.Utils.Lang
356
357**参数:**
358
359| 参数名 | 类型 | 必填 | 说明 |
360| -------- | -------- | -------- | -------- |
361| key | T | 是 | 指定key。 |
362
363**返回值:**
364
365| 类型 | 说明 |
366| -------- | -------- |
367| T | 返回删除元素的值。 |
368
369**错误码:**
370
371以下错误码的详细介绍请参见[语言基础类库错误码](errorcode-utils.md)。
372
373| 错误码ID | 错误信息 |
374| -------- | -------- |
375| 10200011 | The remove method cannot be bound. |
376
377**示例:**
378
379```ts
380let lightWeightSet = new LightWeightSet<string>();
381lightWeightSet.add("squirrel");
382lightWeightSet.add("sparrow");
383let result = lightWeightSet.remove("sparrow");
384console.info("result:", result);  // result: sparrow
385```
386
387
388### removeAt
389
390removeAt(index: number): boolean
391
392删除指定下标所对应的元素。
393
394**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
395
396**系统能力:** SystemCapability.Utils.Lang
397
398**参数:**
399
400| 参数名 | 类型 | 必填 | 说明 |
401| -------- | -------- | -------- | -------- |
402| index | number | 是 | 指定下标。需要小于等于int32_max即2147483647。 |
403
404**返回值:**
405
406| 类型 | 说明 |
407| -------- | -------- |
408| boolean | 确认是否成功删除元素,成功删除元素返回true,否则返回false。 |
409
410**错误码:**
411
412以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[语言基础类库错误码](errorcode-utils.md)。
413
414| 错误码ID | 错误信息 |
415| -------- | -------- |
416| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
417| 10200011 | The removeAt method cannot be bound. |
418
419**示例:**
420
421```ts
422let lightWeightSet = new LightWeightSet<string>();
423lightWeightSet.add("squirrel");
424lightWeightSet.add("sparrow");
425let result = lightWeightSet.removeAt(1);
426console.info("result:", result);  // result: true
427```
428
429
430### getValueAt
431
432getValueAt(index: number): T
433
434获取容器中指定下标对应的元素。
435
436**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
437
438**系统能力:** SystemCapability.Utils.Lang
439
440**参数:**
441
442| 参数名 | 类型 | 必填 | 说明 |
443| -------- | -------- | -------- | -------- |
444| index | number | 是 | 指定下标。需要小于等于int32_max即2147483647。 |
445
446**返回值:**
447
448| 类型 | 说明 |
449| -------- | -------- |
450| T | 返回指定下标对应的元素。 |
451
452**错误码:**
453
454以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[语言基础类库错误码](errorcode-utils.md)。
455
456| 错误码ID | 错误信息 |
457| -------- | -------- |
458| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
459| 10200011 | The getValueAt method cannot be bound. |
460
461**参数:**
462
463```ts
464let lightWeightSet = new LightWeightSet<string>();
465lightWeightSet.add("squirrel");
466lightWeightSet.add("sparrow");
467let result = lightWeightSet.getValueAt(1);
468console.info("result:", result);  // result: squirrel
469```
470
471
472### clear
473
474clear(): void
475
476清除容器中的所有元素,并将length置为0。
477
478**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
479
480**系统能力:** SystemCapability.Utils.Lang
481
482**错误码:**
483
484以下错误码的详细介绍请参见[语言基础类库错误码](errorcode-utils.md)。
485
486| 错误码ID | 错误信息 |
487| -------- | -------- |
488| 10200011 | The clear method cannot be bound. |
489
490**示例:**
491
492```ts
493let lightWeightSet = new LightWeightSet<string>();
494lightWeightSet.add("squirrel");
495lightWeightSet.add("sparrow");
496lightWeightSet.clear();
497let result = lightWeightSet.isEmpty();
498console.info("result:", result);  // result: true
499```
500
501
502### toString
503
504toString(): String
505
506获取包含容器中所有键和值的字符串。
507
508**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
509
510**系统能力:** SystemCapability.Utils.Lang
511
512**返回值:**
513
514| 类型 | 说明 |
515| -------- | -------- |
516| String | 返回对应字符串。 |
517
518**示例:**
519
520```ts
521let lightWeightSet = new LightWeightSet<string>();
522lightWeightSet.add("squirrel");
523lightWeightSet.add("sparrow");
524let result = lightWeightSet.toString();
525console.info("result:", result);  // result: sparrow,squirrel
526```
527
528
529### toArray
530
531toArray(): Array&lt;T&gt;
532
533获取包含此容器中所有对象的数组。
534
535**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
536
537**系统能力:** SystemCapability.Utils.Lang
538
539**返回值:**
540
541| 类型 | 说明 |
542| -------- | -------- |
543| Array&lt;T&gt; | 返回对应数组。 |
544
545**错误码:**
546
547以下错误码的详细介绍请参见[语言基础类库错误码](errorcode-utils.md)。
548
549| 错误码ID | 错误信息 |
550| -------- | -------- |
551| 10200011 | The toArray method cannot be bound. |
552
553**示例:**
554
555```ts
556let lightWeightSet = new LightWeightSet<string>();
557lightWeightSet.add("squirrel");
558lightWeightSet.add("sparrow");
559let result = lightWeightSet.toArray();
560```
561
562
563### values
564
565values(): IterableIterator&lt;T&gt;
566
567返回包含此映射中所有键值的新迭代器对象。
568
569**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
570
571**系统能力:** SystemCapability.Utils.Lang
572
573**返回值:**
574
575| 类型 | 说明 |
576| -------- | -------- |
577| IterableIterator&lt;T&gt; | 返回一个迭代器。 |
578
579**错误码:**
580
581以下错误码的详细介绍请参见[语言基础类库错误码](errorcode-utils.md)。
582
583| 错误码ID | 错误信息 |
584| -------- | -------- |
585| 10200011 | The values method cannot be bound. |
586
587**示例:**
588
589```ts
590let lightWeightSet = new LightWeightSet<string>();
591lightWeightSet.add("squirrel");
592lightWeightSet.add("sparrow");
593let values = lightWeightSet.values();
594for (let value of values) {
595  console.info("value:", value);
596}
597// value: sparrow
598// value: squirrel
599```
600
601
602### forEach
603
604forEach(callbackFn: (value?: T, key?: T, set?: LightWeightSet&lt;T&gt;) => void, thisArg?: Object): void
605
606通过回调函数来遍历LightWeightSet实例对象上的元素以及元素对应的下标。
607
608**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
609
610**系统能力:** SystemCapability.Utils.Lang
611
612**参数:**
613
614| 参数名 | 类型 | 必填 | 说明 |
615| -------- | -------- | -------- | -------- |
616| callbackFn | function | 是 | 回调函数。 |
617| thisArg | Object | 否 | callbackFn被调用时用作this值,默认值为当前实例对象。 |
618
619callbackFn的参数说明:
620| 参数名 | 类型 | 必填 | 说明 |
621| -------- | -------- | -------- | -------- |
622| value | T | 否 | 当前遍历到的元素键值对的值,默认值为首个键值对的值。 |
623| key | T | 否 | 当前遍历到的元素键值对的键(和value相同),默认值为首个键值对的键。 |
624| set | LightWeightSet&lt;T&gt; | 否 | 当前调用forEach方法的实例对象,默认值为当前实例对象。 |
625
626**错误码:**
627
628以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[语言基础类库错误码](errorcode-utils.md)。
629
630| 错误码ID | 错误信息 |
631| -------- | -------- |
632| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
633| 10200011 | The forEach method cannot be bound. |
634
635**示例:**
636
637```ts
638let lightWeightSet = new LightWeightSet<string>();
639lightWeightSet.add("sparrow");
640lightWeightSet.add("gull");
641lightWeightSet.forEach((value: string, key: string) => {
642  console.info("value:" + value, "key:" + key);
643});
644// value:gull key:gull
645// value:sparrow key:sparrow
646```
647
648```ts
649// 不建议在forEach函数中使用add、remove、removeAt方法,会导致死循环等不可预知的风险,可使用for循环来进行插入和删除。
650let lightWeightSet = new LightWeightSet<string>();
651for(let i = 0; i < 10; i++) {
652  lightWeightSet.add(i + "123");
653}
654for(let i = 0; i < 10; i++) {
655  lightWeightSet.remove(i + "123");
656}
657```
658
659### entries
660
661entries(): IterableIterator<[T, T]>
662
663返回包含此映射中包含的键值对的新迭代器对象。
664
665**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
666
667**系统能力:** SystemCapability.Utils.Lang
668
669**返回值:**
670
671| 类型 | 说明 |
672| -------- | -------- |
673| IterableIterator<[T, T]> | 返回一个迭代器。 |
674
675**错误码:**
676
677以下错误码的详细介绍请参见[语言基础类库错误码](errorcode-utils.md)。
678
679| 错误码ID | 错误信息 |
680| -------- | -------- |
681| 10200011 | The entries method cannot be bound. |
682
683**示例:**
684
685```ts
686let lightWeightSet = new LightWeightSet<string>();
687lightWeightSet.add("squirrel");
688lightWeightSet.add("sparrow");
689let iter = lightWeightSet.entries();
690for (let item of iter) {
691  console.info("value:", item[1])
692}
693// value: sparrow
694// value: squirrel
695```
696
697```ts
698// 不建议在entries中使用add、remove、removeAt方法,会导致死循环等不可预知的风险,可使用for循环来进行插入和删除。
699let lightWeightSet = new LightWeightSet<string>();
700for(let i = 0; i < 10; i++) {
701  lightWeightSet.add(i + "123");
702}
703for(let i = 0; i < 10; i++) {
704  lightWeightSet.remove(i + "123");
705}
706```
707
708### [Symbol.iterator]
709
710[Symbol.iterator]\(): IterableIterator&lt;T&gt;
711
712返回一个迭代器,迭代器的每一项都是一个JavaScript对象。
713
714**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
715
716**系统能力:** SystemCapability.Utils.Lang
717
718**返回值:**
719
720| 类型 | 说明 |
721| -------- | -------- |
722| IterableIterator&lt;T&gt; | 返回一个迭代器。 |
723
724**错误码:**
725
726以下错误码的详细介绍请参见[语言基础类库错误码](errorcode-utils.md)。
727
728| 错误码ID | 错误信息 |
729| -------- | -------- |
730| 10200011 | The Symbol.iterator method cannot be bound. |
731
732**示例:**
733
734```ts
735let lightWeightSet = new LightWeightSet<string>();
736lightWeightSet.add("squirrel");
737lightWeightSet.add("sparrow");
738
739// 使用方法一:
740for (let value of lightWeightSet) {
741  console.info("value:", value);
742}
743// value: sparrow
744// value: squirrel
745
746// 使用方法二:
747let iter = lightWeightSet[Symbol.iterator]();
748let temp: IteratorResult<string> = iter.next();
749while(!temp.done) {
750  console.info("value:", temp.value);
751  temp = iter.next();
752}
753// value: sparrow
754// value: squirrel
755```
756
757```ts
758// 不建议在Symbol.iterator中使用add、remove、removeAt方法,会导致死循环等不可预知的风险,可使用for循环来进行插入和删除。
759let lightWeightSet = new LightWeightSet<string>();
760for(let i = 0; i < 10; i++) {
761  lightWeightSet.add(i + "123");
762}
763for(let i = 0; i < 10; i++) {
764  lightWeightSet.remove(i + "123");
765}
766```
767
768
769### equal<sup>(deprecated)</sup>
770
771equal(obj: Object): boolean
772
773判断此容器与obj的构成元素是否相同。
774
775> **说明:**
776>
777> 此接口从API version 8开始支持,从API version 12开始废弃。无替代接口。
778
779**系统能力:** SystemCapability.Utils.Lang
780
781**参数:**
782
783| 参数名 | 类型 | 必填 | 说明 |
784| -------- | -------- | -------- | -------- |
785| obj | Object | 是 | 比较对象。 |
786
787**返回值:**
788
789| 类型 | 说明 |
790| -------- | -------- |
791| boolean | 当obj为仅含string或number的LightWeightSet或数组,且对象内部元素构成相同时,返回true;其它情况返回false。 |
792
793**错误码:**
794
795以下错误码的详细介绍请参见[语言基础类库错误码](errorcode-utils.md)。
796
797| 错误码ID | 错误信息 |
798| -------- | -------- |
799| 10200011 | The equal method cannot be bound. |
800
801**示例:**
802
803```ts
804let lightWeightSet = new LightWeightSet<string>();
805lightWeightSet.add("squirrel");
806lightWeightSet.add("sparrow");
807let obj = ["sparrow", "squirrel"];
808let result = lightWeightSet.equal(obj);
809console.info("result:", result);  // result: true
810```