diff options
author | Araq <rumpf_a@web.de> | 2012-08-22 22:46:02 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-08-22 22:46:02 +0200 |
commit | f8931798899647b65ebb7d7dcf28d6976da599ce (patch) | |
tree | 0fdbd7f0b5516279458d21bf99a698cb2cb89e37 /lib/pure/collections/lists.nim | |
parent | a95e958046447d0ef88d93337171d4b8339348a4 (diff) | |
download | Nim-f8931798899647b65ebb7d7dcf28d6976da599ce.tar.gz |
documented hygienic templates; made tests green; fixed system.clamp
Diffstat (limited to 'lib/pure/collections/lists.nim')
-rwxr-xr-x | lib/pure/collections/lists.nim | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/pure/collections/lists.nim b/lib/pure/collections/lists.nim index adfd9ceb4..ad8eca6a9 100755 --- a/lib/pure/collections/lists.nim +++ b/lib/pure/collections/lists.nim @@ -11,6 +11,9 @@ ## to do so, the 'next' and 'prev' pointers are not hidden from you and can ## be manipulated directly for efficiency. +when not defined(nimhygiene): + {.pragma: dirty.} + type TDoublyLinkedNode* {.pure, final.}[T] = object ## a node a doubly linked list consists of @@ -62,13 +65,13 @@ proc newSinglyLinkedNode*[T](value: T): PSinglyLinkedNode[T] = new(result) result.value = value -template itemsListImpl() = +template itemsListImpl() {.dirty.} = var it = L.head while it != nil: yield it.value it = it.next -template itemsRingImpl() = +template itemsRingImpl() {.dirty.} = var it = L.head if it != nil: while true: @@ -76,14 +79,14 @@ template itemsRingImpl() = it = it.next if it == L.head: break -template nodesListImpl() = +template nodesListImpl() {.dirty.} = var it = L.head while it != nil: var nxt = it.next yield it it = nxt -template nodesRingImpl() = +template nodesRingImpl() {.dirty.} = var it = L.head if it != nil: while true: @@ -92,7 +95,7 @@ template nodesRingImpl() = it = nxt if it == L.head: break -template findImpl() = +template findImpl() {.dirty.} = for x in nodes(L): if x.value == value: return x @@ -132,7 +135,7 @@ iterator nodes*[T](L: TDoublyLinkedRing[T]): PDoublyLinkedNode[T] = ## list during traversal is supported. nodesRingImpl() -template dollarImpl() = +template dollarImpl() {.dirty.} = result = "[" for x in nodes(L): if result.len > 1: result.add(", ") |