mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-14 23:33:28 +00:00
move toDeque to after addLast (#19233) [backport:1.0]
Changes the order of procs definitions in order to avoid calling an undefined proc.
(cherry picked from commit c989542339)
This commit is contained in:
committed by
narimiran
parent
ac57c3193d
commit
83c472c40d
@@ -87,20 +87,6 @@ proc initDeque*[T](initialSize: int = defaultInitialSize): Deque[T] =
|
||||
## * `toDeque proc <#toDeque,openArray[T]>`_
|
||||
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.} =
|
||||
## Returns the number of elements of `deq`.
|
||||
result = deq.count
|
||||
@@ -303,6 +289,20 @@ proc addLast*[T](deq: var Deque[T], item: sink T) =
|
||||
deq.data[deq.tail] = item
|
||||
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.} =
|
||||
## Returns the first element of `deq`, but does not remove it from the deque.
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user