File tree Expand file tree Collapse file tree 4 files changed +934
-0
lines changed Expand file tree Collapse file tree 4 files changed +934
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import {make as makeStructType} from "./type-class/struct-type";
7
7
import { make as makeObjectType } from "./type-class/object-type" ;
8
8
import { make as makeArrayType } from "./type-class/array-type" ;
9
9
import { make as makeHashMapType } from "./type-class/hash-map-type" ;
10
+ import { make as makeHashSetType } from "./type-class/hash-set-type" ;
10
11
11
12
import { make as makeStringPool } from "./string-pool" ;
12
13
@@ -41,6 +42,7 @@ export class Realm {
41
42
ArrayType: Class < TypeClass < ArrayType < any >>> ;
42
43
StringType: Class < TypeClass < PrimitiveType < string >>> ;
43
44
HashMapType: Class < TypeClass < HashMapType < any , any >>> ;
45
+ HashSetType: Class < TypeClass < HashSetType < any , any >>> ;
44
46
45
47
T: {
46
48
[ name : string | Symbol ] : Type ;
@@ -68,6 +70,7 @@ export class Realm {
68
70
this . ArrayType = makeArrayType ( this ) ;
69
71
this . StringType = makeStringType ( this ) ;
70
72
this . HashMapType = makeHashMapType ( this ) ;
73
+ this . HashSetType = makeHashSetType ( this ) ;
71
74
this . isInitialized = false ;
72
75
}
73
76
Original file line number Diff line number Diff line change
1
+ # HashSetType
2
+
3
+ A type class for typed hash sets. Takes an element type as input and produces a hash set type which can store elements of that type.
4
+
5
+ Usage:
6
+
7
+ ``` js
8
+ const {HashSetType , T } = realm;
9
+
10
+ const StringSet = new HashSetType (T .String );
11
+
12
+ const set = new StringSet ();
13
+
14
+ set .add (' hello world' );
15
+ set .add (' foo bar' );
16
+
17
+ set .has (' hello world' ); // true
18
+
19
+ for (const entry of set) {
20
+ console .log (entry);
21
+ }
22
+
23
+ set .delete (' foo bar' );
24
+ ```
You can’t perform that action at this time.
0 commit comments