mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-13 06:43:52 +00:00
* Update lists.nim
* Update tlists.nim
(cherry picked from commit 526a32e169)
This commit is contained in:
@@ -676,12 +676,12 @@ proc addMoved*[T](a, b: var DoublyLinkedList[T]) {.since: (1, 5, 1).} =
|
||||
assert s == [0, 1, 0, 1, 0, 1]
|
||||
|
||||
if b.head != nil:
|
||||
b.head.prev = a.tail
|
||||
if a.tail != nil:
|
||||
a.tail.next = b.head
|
||||
a.tail = b.tail
|
||||
if a.head == nil:
|
||||
a.head = b.head
|
||||
if a.head == nil:
|
||||
a.head = b.head
|
||||
else:
|
||||
b.head.prev = a.tail
|
||||
a.tail.next = b.head
|
||||
a.tail = b.tail
|
||||
if a.addr != b.addr:
|
||||
b.head = nil
|
||||
b.tail = nil
|
||||
|
||||
@@ -245,6 +245,18 @@ template main =
|
||||
doAssert a.toSeq == @[1]
|
||||
a.add(2)
|
||||
doAssert a.toSeq == @[1, 2]
|
||||
|
||||
block issue19314: # add (appends a shallow copy)
|
||||
var a: DoublyLinkedList[int]
|
||||
var b: DoublyLinkedList[int]
|
||||
|
||||
doAssert a.toSeq == @[]
|
||||
a.add(1)
|
||||
doAssert a.toSeq == @[1]
|
||||
a.add(b)
|
||||
doAssert a.toSeq == @[1]
|
||||
a.add(2)
|
||||
doAssert a.toSeq == @[1, 2]
|
||||
|
||||
static: main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user