mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Update Set to no longer use Nat
This commit is contained in:
parent
97f21e65fe
commit
77a10986d6
1 changed files with 9 additions and 9 deletions
|
@ -28,7 +28,7 @@ interface Set
|
||||||
List,
|
List,
|
||||||
Bool.{ Bool, Eq },
|
Bool.{ Bool, Eq },
|
||||||
Dict.{ Dict },
|
Dict.{ Dict },
|
||||||
Num.{ Nat },
|
Num.{ U64 },
|
||||||
Hash.{ Hash, Hasher },
|
Hash.{ Hash, Hasher },
|
||||||
Inspect.{ Inspect, Inspector, InspectFormatter },
|
Inspect.{ Inspect, Inspector, InspectFormatter },
|
||||||
]
|
]
|
||||||
|
@ -80,12 +80,12 @@ empty = \{} -> @Set (Dict.empty {})
|
||||||
## Return a set with space allocated for a number of entries. This
|
## 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
|
## may provide a performance optimization if you know how many entries will be
|
||||||
## inserted.
|
## inserted.
|
||||||
withCapacity : Nat -> Set *
|
withCapacity : U64 -> Set *
|
||||||
withCapacity = \cap ->
|
withCapacity = \cap ->
|
||||||
@Set (Dict.withCapacity cap)
|
@Set (Dict.withCapacity cap)
|
||||||
|
|
||||||
## Enlarge the set for at least capacity additional elements
|
## 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 ->
|
reserve = \@Set dict, requested ->
|
||||||
@Set (Dict.reserve dict requested)
|
@Set (Dict.reserve dict requested)
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ expect
|
||||||
##
|
##
|
||||||
## expect countValues == 3
|
## expect countValues == 3
|
||||||
## ```
|
## ```
|
||||||
len : Set * -> Nat
|
len : Set * -> U64
|
||||||
len = \@Set dict ->
|
len = \@Set dict ->
|
||||||
Dict.len dict
|
Dict.len dict
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ len = \@Set dict ->
|
||||||
##
|
##
|
||||||
## capacityOfSet = Set.capacity foodSet
|
## capacityOfSet = Set.capacity foodSet
|
||||||
## ```
|
## ```
|
||||||
capacity : Set * -> Nat
|
capacity : Set * -> U64
|
||||||
capacity = \@Set dict ->
|
capacity = \@Set dict ->
|
||||||
Dict.capacity dict
|
Dict.capacity dict
|
||||||
|
|
||||||
|
@ -462,22 +462,22 @@ expect
|
||||||
x == fromList (toList x)
|
x == fromList (toList x)
|
||||||
|
|
||||||
expect
|
expect
|
||||||
orderOne : Set Nat
|
orderOne : Set U64
|
||||||
orderOne =
|
orderOne =
|
||||||
single 1
|
single 1
|
||||||
|> insert 2
|
|> insert 2
|
||||||
|
|
||||||
orderTwo : Set Nat
|
orderTwo : Set U64
|
||||||
orderTwo =
|
orderTwo =
|
||||||
single 2
|
single 2
|
||||||
|> insert 1
|
|> insert 1
|
||||||
|
|
||||||
wrapperOne : Set (Set Nat)
|
wrapperOne : Set (Set U64)
|
||||||
wrapperOne =
|
wrapperOne =
|
||||||
single orderOne
|
single orderOne
|
||||||
|> insert orderTwo
|
|> insert orderTwo
|
||||||
|
|
||||||
wrapperTwo : Set (Set Nat)
|
wrapperTwo : Set (Set U64)
|
||||||
wrapperTwo =
|
wrapperTwo =
|
||||||
single orderTwo
|
single orderTwo
|
||||||
|> insert orderOne
|
|> insert orderOne
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue