Moves TSet procs to their code block.
This commit is contained in:
parent
cdecac11c2
commit
dd47fa9037
1 changed files with 21 additions and 21 deletions
|
|
@ -238,6 +238,27 @@ proc disjoint*[A](s1, s2: TSet[A]): bool =
|
||||||
if item in s2: return false
|
if item in s2: return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
proc `<`*[A](s, t: TSet[A]): bool =
|
||||||
|
## Is s a strict subset of t?
|
||||||
|
s.counter != t.counter and s <= t
|
||||||
|
|
||||||
|
proc `<=`*[A](s, t: TSet[A]): bool =
|
||||||
|
## Is s a subset of t?
|
||||||
|
result = false
|
||||||
|
if s.counter > t.counter: return
|
||||||
|
result = true
|
||||||
|
for item in s:
|
||||||
|
if not(t.contains(item)):
|
||||||
|
result = false
|
||||||
|
return
|
||||||
|
|
||||||
|
proc `==`*[A](s, t: TSet[A]): bool =
|
||||||
|
s.counter == t.counter and s <= t
|
||||||
|
|
||||||
|
proc map*[A, B](data: TSet[A], op: proc (x: A): B {.closure.}): TSet[B] =
|
||||||
|
result = initSet[B]()
|
||||||
|
for item in data: result.incl(op(item))
|
||||||
|
|
||||||
# ------------------------------ ordered set ------------------------------
|
# ------------------------------ ordered set ------------------------------
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -351,27 +372,6 @@ proc `$`*[A](s: TOrderedSet[A]): string =
|
||||||
assert s.isValid, "The set needs to be initialized."
|
assert s.isValid, "The set needs to be initialized."
|
||||||
dollarImpl()
|
dollarImpl()
|
||||||
|
|
||||||
proc `<`*[A](s, t: TSet[A]): bool =
|
|
||||||
## Is s a strict subset of t?
|
|
||||||
s.counter != t.counter and s <= t
|
|
||||||
|
|
||||||
proc `<=`*[A](s, t: TSet[A]): bool =
|
|
||||||
## Is s a subset of t?
|
|
||||||
result = false
|
|
||||||
if s.counter > t.counter: return
|
|
||||||
result = true
|
|
||||||
for item in s:
|
|
||||||
if not(t.contains(item)):
|
|
||||||
result = false
|
|
||||||
return
|
|
||||||
|
|
||||||
proc `==`*[A](s, t: TSet[A]): bool =
|
|
||||||
s.counter == t.counter and s <= t
|
|
||||||
|
|
||||||
proc map*[A, B](data: TSet[A], op: proc (x: A): B {.closure.}): TSet[B] =
|
|
||||||
result = initSet[B]()
|
|
||||||
for item in data: result.incl(op(item))
|
|
||||||
|
|
||||||
proc testModule() =
|
proc testModule() =
|
||||||
## Internal micro test to validate docstrings and such.
|
## Internal micro test to validate docstrings and such.
|
||||||
block isValidTest:
|
block isValidTest:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue