move toDeque to after addLast (#19233) [backport:1.0]
Changes the order of procs definitions in order to avoid calling an undefined proc.
This commit is contained in:
parent
d39147219a
commit
c989542339
1 changed files with 14 additions and 14 deletions
|
|
@ -87,20 +87,6 @@ proc initDeque*[T](initialSize: int = defaultInitialSize): Deque[T] =
|
||||||
## * `toDeque proc <#toDeque,openArray[T]>`_
|
## * `toDeque proc <#toDeque,openArray[T]>`_
|
||||||
result.initImpl(initialSize)
|
result.initImpl(initialSize)
|
||||||
|
|
||||||
proc toDeque*[T](x: openArray[T]): Deque[T] {.since: (1, 3).} =
|
|
||||||
## Creates a new deque that contains the elements of `x` (in the same order).
|
|
||||||
##
|
|
||||||
## **See also:**
|
|
||||||
## * `initDeque proc <#initDeque,int>`_
|
|
||||||
runnableExamples:
|
|
||||||
let a = toDeque([7, 8, 9])
|
|
||||||
assert len(a) == 3
|
|
||||||
assert $a == "[7, 8, 9]"
|
|
||||||
|
|
||||||
result.initImpl(x.len)
|
|
||||||
for item in items(x):
|
|
||||||
result.addLast(item)
|
|
||||||
|
|
||||||
proc len*[T](deq: Deque[T]): int {.inline.} =
|
proc len*[T](deq: Deque[T]): int {.inline.} =
|
||||||
## Returns the number of elements of `deq`.
|
## Returns the number of elements of `deq`.
|
||||||
result = deq.count
|
result = deq.count
|
||||||
|
|
@ -303,6 +289,20 @@ proc addLast*[T](deq: var Deque[T], item: sink T) =
|
||||||
deq.data[deq.tail] = item
|
deq.data[deq.tail] = item
|
||||||
deq.tail = (deq.tail + 1) and deq.mask
|
deq.tail = (deq.tail + 1) and deq.mask
|
||||||
|
|
||||||
|
proc toDeque*[T](x: openArray[T]): Deque[T] {.since: (1, 3).} =
|
||||||
|
## Creates a new deque that contains the elements of `x` (in the same order).
|
||||||
|
##
|
||||||
|
## **See also:**
|
||||||
|
## * `initDeque proc <#initDeque,int>`_
|
||||||
|
runnableExamples:
|
||||||
|
let a = toDeque([7, 8, 9])
|
||||||
|
assert len(a) == 3
|
||||||
|
assert $a == "[7, 8, 9]"
|
||||||
|
|
||||||
|
result.initImpl(x.len)
|
||||||
|
for item in items(x):
|
||||||
|
result.addLast(item)
|
||||||
|
|
||||||
proc peekFirst*[T](deq: Deque[T]): lent T {.inline.} =
|
proc peekFirst*[T](deq: Deque[T]): lent T {.inline.} =
|
||||||
## Returns the first element of `deq`, but does not remove it from the deque.
|
## Returns the first element of `deq`, but does not remove it from the deque.
|
||||||
##
|
##
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue