|
@@ -6,12 +6,14 @@ bbdoc: Data structures/Linked lists
|
|
End Rem
|
|
End Rem
|
|
Module BRL.LinkedList
|
|
Module BRL.LinkedList
|
|
|
|
|
|
-ModuleInfo "Version: 1.09"
|
|
|
|
|
|
+ModuleInfo "Version: 1.10"
|
|
ModuleInfo "Author: Mark Sibly"
|
|
ModuleInfo "Author: Mark Sibly"
|
|
ModuleInfo "License: zlib/libpng"
|
|
ModuleInfo "License: zlib/libpng"
|
|
ModuleInfo "Copyright: Blitz Research Ltd"
|
|
ModuleInfo "Copyright: Blitz Research Ltd"
|
|
ModuleInfo "Modserver: BRL"
|
|
ModuleInfo "Modserver: BRL"
|
|
|
|
|
|
|
|
+ModuleInfo "History: 1.10"
|
|
|
|
+ModuleInfo "History: Fixed TLink removal during iteration issue."
|
|
ModuleInfo "History: 1.09"
|
|
ModuleInfo "History: 1.09"
|
|
ModuleInfo "History: Added internal count."
|
|
ModuleInfo "History: Added internal count."
|
|
ModuleInfo "History: (Debug) Assertion on modification during iteration."
|
|
ModuleInfo "History: (Debug) Assertion on modification during iteration."
|
|
@@ -40,6 +42,7 @@ Type TLink
|
|
|
|
|
|
Field _value:Object
|
|
Field _value:Object
|
|
Field _succ:TLink,_pred:TLink
|
|
Field _succ:TLink,_pred:TLink
|
|
|
|
+ Field _iterHold:Int, _remove:Int
|
|
|
|
|
|
Rem
|
|
Rem
|
|
bbdoc: Returns the Object associated with this Link.
|
|
bbdoc: Returns the Object associated with this Link.
|
|
@@ -69,8 +72,11 @@ Type TLink
|
|
_value=Null
|
|
_value=Null
|
|
_succ._pred=_pred
|
|
_succ._pred=_pred
|
|
_pred._succ=_succ
|
|
_pred._succ=_succ
|
|
- _pred=Null
|
|
|
|
- _succ=Null
|
|
|
|
|
|
+ _remove = True
|
|
|
|
+ If Not _iterHold
|
|
|
|
+ _pred=Null
|
|
|
|
+ _succ=Null
|
|
|
|
+ End If
|
|
End Method
|
|
End Method
|
|
|
|
|
|
End Type
|
|
End Type
|
|
@@ -116,7 +122,22 @@ Type TListEnum
|
|
?
|
|
?
|
|
Local value:Object=_link._value
|
|
Local value:Object=_link._value
|
|
Assert value<>_link
|
|
Assert value<>_link
|
|
|
|
+
|
|
|
|
+ Local tmp:TLink = _link
|
|
|
|
+
|
|
_link=_link._succ
|
|
_link=_link._succ
|
|
|
|
+
|
|
|
|
+ If _link Then
|
|
|
|
+ _link._iterHold :+ 1
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ tmp._iterHold :- 1
|
|
|
|
+
|
|
|
|
+ If tmp._remove And tmp._iterHold <= 0 Then
|
|
|
|
+ tmp._pred=Null
|
|
|
|
+ tmp._succ=Null
|
|
|
|
+ End If
|
|
|
|
+
|
|
Return value
|
|
Return value
|
|
End Method
|
|
End Method
|
|
|
|
|
|
@@ -158,6 +179,7 @@ Type TList
|
|
End Rem
|
|
End Rem
|
|
Method Clear()
|
|
Method Clear()
|
|
While _head._succ<>_head
|
|
While _head._succ<>_head
|
|
|
|
+ _head._iterHold = 0
|
|
_head._succ.Remove
|
|
_head._succ.Remove
|
|
Wend
|
|
Wend
|
|
?ngcmod
|
|
?ngcmod
|