Merge branch 'devel' into sighashes

This commit is contained in:
Araq 2016-12-13 12:18:45 +01:00
commit 414c2decbe
9 changed files with 37 additions and 16 deletions

View file

@ -160,7 +160,10 @@ proc peekLast*[T](deq: Deque[T]): T {.inline.} =
emptyCheck(deq)
result = deq.data[(deq.tail - 1) and deq.mask]
proc default[T](t: typedesc[T]): T {.inline.} = discard
template default[T](t: typedesc[T]): T =
var v: T
v
proc popFirst*[T](deq: var Deque[T]): T {.inline, discardable.} =
## Remove and returns the first element of the `deq`.
emptyCheck(deq)

View file

@ -154,7 +154,10 @@ proc add*[T](q: var Queue[T], item: T) =
q.data[q.wr] = item
q.wr = (q.wr + 1) and q.mask
proc default[T](t: typedesc[T]): T {.inline.} = discard
template default[T](t: typedesc[T]): T =
var v: T
v
proc pop*[T](q: var Queue[T]): T {.inline, discardable.} =
## Remove and returns the first (oldest) element of the queue `q`.
emptyCheck(q)

View file

@ -261,7 +261,9 @@ template doWhile(a, b) =
b
if not a: break
proc default[T](t: typedesc[T]): T {.inline.} = discard
template default[T](t: typedesc[T]): T =
var v: T
v
proc excl*[A](s: var HashSet[A], key: A) =
## Excludes `key` from the set `s`.

View file

@ -954,7 +954,7 @@ proc inc*[A](t: var CountTable[A], key: A, val = 1) =
inc(t.counter)
proc smallest*[A](t: CountTable[A]): tuple[key: A, val: int] =
## returns the largest (key,val)-pair. Efficiency: O(n)
## returns the (key,val)-pair with the smallest `val`. Efficiency: O(n)
assert t.len > 0
var minIdx = 0
for h in 1..high(t.data):
@ -1080,7 +1080,7 @@ proc inc*[A](t: CountTableRef[A], key: A, val = 1) =
t[].inc(key, val)
proc smallest*[A](t: CountTableRef[A]): (A, int) =
## returns the largest (key,val)-pair. Efficiency: O(n)
## returns the (key,val)-pair with the smallest `val`. Efficiency: O(n)
t[].smallest
proc largest*[A](t: CountTableRef[A]): (A, int) =

View file

@ -76,7 +76,7 @@ to a variable (that was passed to the ``scanf`` macro) while ``$[]`` merely
optional tokens.
In this example, we define a helper proc ``skipSep`` that skips some separators
In this example, we define a helper proc ``someSep`` that skips some separators
which we then use in our scanf pattern to help us in the matching process:
.. code-block:: nim
@ -86,14 +86,14 @@ which we then use in our scanf pattern to help us in the matching process:
result = 0
while input[start+result] in seps: inc result
if scanf(input, "$w${someSep}$w", key, value):
if scanf(input, "$w$[someSep]$w", key, value):
...
It also possible to pass arguments to a user definable matcher:
.. code-block:: nim
proc ndigits(input: string; start: int; intVal: var int; n: int): int =
proc ndigits(input: string; intVal: var int; start: int; n: int): int =
# matches exactly ``n`` digits. Matchers need to return 0 if nothing
# matched or otherwise the number of processed chars.
var x = 0