diff options
Diffstat (limited to 'compiler/lists.nim')
-rw-r--r-- | compiler/lists.nim | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/compiler/lists.nim b/compiler/lists.nim index 22b1a183a..dd4f5d6be 100644 --- a/compiler/lists.nim +++ b/compiler/lists.nim @@ -20,17 +20,17 @@ type PStrEntry* = ref TStrEntry TLinkedList* = object # for the "find" operation: head*, tail*: PListEntry - Counter*: int + counter*: int - TCompareProc* = proc (entry: PListEntry, closure: Pointer): bool {.nimcall.} + TCompareProc* = proc (entry: PListEntry, closure: pointer): bool {.nimcall.} -proc InitLinkedList*(list: var TLinkedList) = - list.Counter = 0 +proc initLinkedList*(list: var TLinkedList) = + list.counter = 0 list.head = nil list.tail = nil -proc Append*(list: var TLinkedList, entry: PListEntry) = - Inc(list.counter) +proc append*(list: var TLinkedList, entry: PListEntry) = + inc(list.counter) entry.next = nil entry.prev = list.tail if list.tail != nil: @@ -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,15 +50,15 @@ 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 = - if Contains(list, data): return true - AppendStr(list, data) # else: add to list +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) = - Inc(list.counter) +proc prepend*(list: var TLinkedList, entry: PListEntry) = + inc(list.counter) entry.prev = nil entry.next = list.head if list.head != nil: @@ -67,22 +67,22 @@ 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) else: - Inc(list.counter) + inc(list.counter) entry.next = pos entry.prev = pos.prev if pos.prev != nil: pos.prev.next = entry pos.prev = entry -proc Remove*(list: var TLinkedList, entry: PListEntry) = - Dec(list.counter) +proc remove*(list: var TLinkedList, entry: PListEntry) = + dec(list.counter) if entry == list.tail: list.tail = entry.prev if entry == list.head: @@ -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 |