This commit is contained in:
hlaaftana
2021-01-03 10:02:12 +03:00
committed by GitHub
parent c71f5650c6
commit 2aed418698

View File

@@ -531,13 +531,14 @@ func commonPrefixLen*[T](c: CritBitTree[T]): int {.inline, since((1, 3)).} =
else: c.root.byte else: c.root.byte
else: 0 else: 0
func toCritBitTree*[A, B](pairs: openArray[(A, B)]): CritBitTree[A] {.since: (1, 3).} = func toCritBitTree*[T](pairs: openArray[(string, T)]): CritBitTree[T] {.since: (1, 3).} =
## Creates a new `CritBitTree` that contains the given `pairs`. ## Creates a new `CritBitTree` that contains the given `pairs`.
runnableExamples: runnableExamples:
doAssert {"a": "0", "b": "1", "c": "2"}.toCritBitTree is CritBitTree[string] doAssert {"a": "0", "b": "1", "c": "2"}.toCritBitTree is CritBitTree[string]
doAssert {"a": 0, "b": 1, "c": 2}.toCritBitTree is CritBitTree[int]
for item in pairs: result.incl item[0], item[1] for item in pairs: result.incl item[0], item[1]
func toCritBitTree*[T](items: openArray[T]): CritBitTree[void] {.since: (1, 3).} = func toCritBitTree*(items: openArray[string]): CritBitTree[void] {.since: (1, 3).} =
## Creates a new `CritBitTree` that contains the given `items`. ## Creates a new `CritBitTree` that contains the given `items`.
runnableExamples: runnableExamples:
doAssert ["a", "b", "c"].toCritBitTree is CritBitTree[void] doAssert ["a", "b", "c"].toCritBitTree is CritBitTree[void]