summary refs log tree commit diff stats
path: root/compiler/lists.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/lists.nim')
-rwxr-xr-xcompiler/lists.nim11
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/lists.nim b/compiler/lists.nim
index 9da4db177..67b32f919 100755
--- a/compiler/lists.nim
+++ b/compiler/lists.nim
@@ -90,6 +90,15 @@ proc Remove*(list: var TLinkedList, entry: PListEntry) =
   if entry.next != nil: entry.next.prev = entry.prev
   if entry.prev != nil: entry.prev.next = entry.next
 
+proc bringToFront*(list: var TLinkedList, entry: PListEntry) =
+  if entry == list.head: return
+  if entry == list.tail: list.tail = entry.prev
+  if entry.next != nil: entry.next.prev = entry.prev
+  if entry.prev != nil: entry.prev.next = entry.next
+  entry.prev = nil
+  entry.next = list.head
+  list.head = entry
+
 proc ExcludeStr*(list: var TLinkedList, data: string) =
   var it = list.head
   while it != nil:
@@ -99,6 +108,6 @@ proc ExcludeStr*(list: var TLinkedList, data: string) =
 
 proc Find*(list: TLinkedList, fn: TCompareProc, closure: Pointer): PListEntry = 
   result = list.head
-  while result != nil: 
+  while result != nil:
     if fn(result, closure): return 
     result = result.next