Update Set to no longer use Nat

This commit is contained in:
Richard Feldman 2024-01-21 14:18:58 -05:00
parent 97f21e65fe
commit 77a10986d6
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B

View file

@ -28,7 +28,7 @@ interface Set
List,
Bool.{ Bool, Eq },
Dict.{ Dict },
Num.{ Nat },
Num.{ U64 },
Hash.{ Hash, Hasher },
Inspect.{ Inspect, Inspector, InspectFormatter },
]
@ -80,12 +80,12 @@ empty = \{} -> @Set (Dict.empty {})
## Return a set with space allocated for a number of entries. This
## may provide a performance optimization if you know how many entries will be
## inserted.
withCapacity : Nat -> Set *
withCapacity : U64 -> Set *
withCapacity = \cap ->
@Set (Dict.withCapacity cap)
## Enlarge the set for at least capacity additional elements
reserve : Set k, Nat -> Set k
reserve : Set k, U64 -> Set k
reserve = \@Set dict, requested ->
@Set (Dict.reserve dict requested)
@ -152,7 +152,7 @@ expect
##
## expect countValues == 3
## ```
len : Set * -> Nat
len : Set * -> U64
len = \@Set dict ->
Dict.len dict
@ -164,7 +164,7 @@ len = \@Set dict ->
##
## capacityOfSet = Set.capacity foodSet
## ```
capacity : Set * -> Nat
capacity : Set * -> U64
capacity = \@Set dict ->
Dict.capacity dict
@ -462,22 +462,22 @@ expect
x == fromList (toList x)
expect
orderOne : Set Nat
orderOne : Set U64
orderOne =
single 1
|> insert 2
orderTwo : Set Nat
orderTwo : Set U64
orderTwo =
single 2
|> insert 1
wrapperOne : Set (Set Nat)
wrapperOne : Set (Set U64)
wrapperOne =
single orderOne
|> insert orderTwo
wrapperTwo : Set (Set Nat)
wrapperTwo : Set (Set U64)
wrapperTwo =
single orderTwo
|> insert orderOne