diff options
Diffstat (limited to 'compiler/lists.nim')
-rw-r--r-- | compiler/lists.nim | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/compiler/lists.nim b/compiler/lists.nim index 22b1a183a..70e177ba3 100644 --- a/compiler/lists.nim +++ b/compiler/lists.nim @@ -24,12 +24,12 @@ type TCompareProc* = proc (entry: PListEntry, closure: Pointer): bool {.nimcall.} -proc InitLinkedList*(list: var TLinkedList) = +proc initLinkedList*(list: var TLinkedList) = list.Counter = 0 list.head = nil list.tail = nil -proc Append*(list: var TLinkedList, entry: PListEntry) = +proc append*(list: var TLinkedList, entry: PListEntry) = Inc(list.counter) entry.next = nil entry.prev = list.tail @@ -39,7 +39,7 @@ proc Append*(list: var TLinkedList, entry: PListEntry) = list.tail = entry if list.head == nil: list.head = entry -proc Contains*(list: TLinkedList, data: string): bool = +proc contains*(list: TLinkedList, data: string): bool = var it = list.head while it != nil: if PStrEntry(it).data == data: @@ -50,14 +50,14 @@ proc newStrEntry(data: string): PStrEntry = new(result) result.data = data -proc AppendStr*(list: var TLinkedList, data: string) = +proc appendStr*(list: var TLinkedList, data: string) = append(list, newStrEntry(data)) -proc IncludeStr*(list: var TLinkedList, data: string): bool = +proc includeStr*(list: var TLinkedList, data: string): bool = if Contains(list, data): return true AppendStr(list, data) # else: add to list -proc Prepend*(list: var TLinkedList, entry: PListEntry) = +proc prepend*(list: var TLinkedList, entry: PListEntry) = Inc(list.counter) entry.prev = nil entry.next = list.head @@ -67,10 +67,10 @@ proc Prepend*(list: var TLinkedList, entry: PListEntry) = list.head = entry if list.tail == nil: list.tail = entry -proc PrependStr*(list: var TLinkedList, data: string) = +proc prependStr*(list: var TLinkedList, data: string) = prepend(list, newStrEntry(data)) -proc InsertBefore*(list: var TLinkedList, pos, entry: PListEntry) = +proc insertBefore*(list: var TLinkedList, pos, entry: PListEntry) = assert(pos != nil) if pos == list.head: prepend(list, entry) @@ -81,7 +81,7 @@ proc InsertBefore*(list: var TLinkedList, pos, entry: PListEntry) = if pos.prev != nil: pos.prev.next = entry pos.prev = entry -proc Remove*(list: var TLinkedList, entry: PListEntry) = +proc remove*(list: var TLinkedList, entry: PListEntry) = Dec(list.counter) if entry == list.tail: list.tail = entry.prev @@ -103,14 +103,14 @@ proc bringToFront*(list: var TLinkedList, entry: PListEntry) = entry.next = list.head list.head = entry -proc ExcludeStr*(list: var TLinkedList, data: string) = +proc excludeStr*(list: var TLinkedList, data: string) = var it = list.head while it != nil: let nxt = it.next if PStrEntry(it).data == data: remove(list, it) it = nxt -proc Find*(list: TLinkedList, fn: TCompareProc, closure: Pointer): PListEntry = +proc find*(list: TLinkedList, fn: TCompareProc, closure: Pointer): PListEntry = result = list.head while result != nil: if fn(result, closure): return |