Bläddra i källkod

Changed brl.map to SuperStrict.

woollybah 6 år sedan
förälder
incheckning
d86eea9e84
5 ändrade filer med 51 tillägg och 38 borttagningar
  1. 19 8
      map.mod/intmap.bmx
  2. 14 12
      map.mod/map.bmx
  3. 6 6
      map.mod/objectmap.bmx
  4. 6 6
      map.mod/ptrmap.bmx
  5. 6 6
      map.mod/stringmap.bmx

+ 19 - 8
map.mod/intmap.bmx

@@ -1,4 +1,4 @@
-Strict
+SuperStrict
 
 
 Extern
@@ -42,7 +42,7 @@ Type TIntMap
 	bbdoc: Checks if the map is empty.
 	about: #True if @map is empty, otherwise #False.
 	End Rem
-	Method IsEmpty()
+	Method IsEmpty:Int()
 		Return bmx_map_intmap_isempty(Varptr _root)
 	End Method
 	
@@ -78,7 +78,7 @@ Type TIntMap
 	bbdoc: Remove a key/value pair from the map.
 	returns: #True if @key was removed, or #False otherwise.
 	End Rem
-	Method Remove( key:Int )
+	Method Remove:Int( key:Int )
 ?ngcmod
 		_modCount :+ 1
 ?
@@ -193,6 +193,8 @@ Type TIntNode
 	Field _root:Byte Ptr
 	Field _nodePtr:Byte Ptr
 	
+	Field _nextNode:Byte Ptr
+	
 	Method Key:Int()
 		Return bmx_map_intmap_key(_nodePtr)
 	End Method
@@ -201,7 +203,7 @@ Type TIntNode
 		Return bmx_map_intmap_value(_nodePtr)
 	End Method
 
-	Method HasNext()
+	Method HasNext:Int()
 		Return bmx_map_intmap_hasnext(_nodePtr, _root)
 	End Method
 	
@@ -209,12 +211,21 @@ Type TIntNode
 		If Not _nodePtr Then
 			_nodePtr = bmx_map_intmap_firstnode(_root)
 		Else
-			_nodePtr = bmx_map_intmap_nextnode(_nodePtr)
+			'_nodePtr = bmx_map_intmap_nextnode(_nodePtr)
+			_nodePtr = _nextNode
+		End If
+
+		If HasNext() Then
+			_nextNode = bmx_map_intmap_nextnode(_nodePtr)
 		End If
 
 		Return Self
 	End Method
 	
+	Method Remove()
+		
+	End Method
+	
 End Type
 
 Rem
@@ -229,7 +240,7 @@ Type TIntKey
 End Type
 
 Type TIntNodeEnumerator
-	Method HasNext()
+	Method HasNext:Int()
 		Local has:Int = _node.HasNext()
 		If Not has Then
 			_map = Null
@@ -245,7 +256,7 @@ Type TIntNodeEnumerator
 		_node=_node.NextNode()
 		Return node
 	End Method
-
+	
 	'***** PRIVATE *****
 		
 	Field _node:TIntNode	
@@ -288,7 +299,7 @@ Type TIntMapEnumerator
 End Type
 
 Type TIntEmptyEnumerator Extends TIntNodeEnumerator
-	Method HasNext() Override
+	Method HasNext:Int() Override
 		_map = Null
 		Return False
 	End Method

+ 14 - 12
map.mod/map.bmx

@@ -1,17 +1,19 @@
 
-Strict
+SuperStrict
 
 Rem
 bbdoc: Data structures/Maps
 End Rem
 Module BRL.Map
 
-ModuleInfo "Version: 1.09"
+ModuleInfo "Version: 1.10"
 ModuleInfo "Author: Mark Sibly"
 ModuleInfo "License: zlib/libpng"
 ModuleInfo "Copyright: Blitz Research Ltd"
 ModuleInfo "Modserver: BRL"
 
+ModuleInfo "History: 1.10"
+ModuleInfo "History: Changed to SuperStrict."
 ModuleInfo "History: 1.09"
 ModuleInfo "History: Added index operator overloads to maps."
 ModuleInfo "History: 1.08"
@@ -127,12 +129,12 @@ Type TNode Extends TKeyValue
 
 	'***** PRIVATE *****
 	
-	Field _color,_parent:TNode=nil,_left:TNode=nil,_right:TNode=nil
+	Field _color:Int,_parent:TNode=nil,_left:TNode=nil,_right:TNode=nil
 
 End Type
 
 Type TNodeEnumerator
-	Method HasNext()
+	Method HasNext:Int()
 		Local has:Int = _node<>nil
 		If Not has Then
 			_map = Null
@@ -215,7 +217,7 @@ Type TMap
 	bbdoc: Checks if the map is empty.
 	about: #True if @map is empty, otherwise #False.
 	End Rem
-	Method IsEmpty()
+	Method IsEmpty:Int()
 		Return _root=nil
 	End Method
 	
@@ -227,7 +229,7 @@ Type TMap
 
 		Assert key Else "Can't insert Null key into map"
 
-		Local node:TNode=_root,parent:TNode=nil,cmp
+		Local node:TNode=_root,parent:TNode=nil,cmp:Int
 		
 		While node<>nil
 			parent=node
@@ -269,7 +271,7 @@ Type TMap
 	bbdoc: Checks if the map contains @key.
 	returns: #True if the map contains @key.
 	End Rem
-	Method Contains( key:Object )
+	Method Contains:Int( key:Object )
 		Return _FindNode( key )<>nil
 	End Method
 
@@ -287,7 +289,7 @@ Type TMap
 	bbdoc: Remove a key/value pair from the map.
 	returns: #True if @key was removed, or #False otherwise.
 	End Rem
-	Method Remove( key:Object )
+	Method Remove:Int( key:Object )
 		Local node:TNode=_FindNode( key )
 		If node=nil Return 0
 		 _RemoveNode node
@@ -378,7 +380,7 @@ Type TMap
 	Method _FindNode:TNode( key:Object )
 		Local node:TNode=_root
 		While node<>nil
-			Local cmp=key.Compare( node._key )
+			Local cmp:Int=key.Compare( node._key )
 			If cmp>0
 				node=node._right
 			Else If cmp<0
@@ -584,7 +586,7 @@ Type TMap
 		Insert(key, value)
 	End Method
 
-	Const RED=-1,BLACK=1
+	Const RED:Int=-1,BLACK:Int=1
 	
 	Field _root:TNode=nil
 	
@@ -614,7 +616,7 @@ Rem
 bbdoc: Checks if a map is empty
 returns: True if @map is empty, otherwise false
 End Rem
-Function MapIsEmpty( map:TMap )
+Function MapIsEmpty:Int( map:TMap )
 	Return map.IsEmpty()
 End Function
 
@@ -641,7 +643,7 @@ Rem
 bbdoc: Checks if a map contains a key
 returns: True if @map contains @key
 End Rem
-Function MapContains( map:TMap,key:Object )
+Function MapContains:Int( map:TMap,key:Object )
 	Return map.Contains( key )
 End Function
 

+ 6 - 6
map.mod/objectmap.bmx

@@ -1,4 +1,4 @@
-Strict
+SuperStrict
 
 
 Extern
@@ -31,7 +31,7 @@ Type TObjectMap
 		bmx_map_objectmap_clear(Varptr _root)
 	End Method
 	
-	Method IsEmpty()
+	Method IsEmpty:Int()
 		Return bmx_map_objectmap_isempty(Varptr _root)
 	End Method
 	
@@ -50,7 +50,7 @@ Type TObjectMap
 		Return bmx_map_objectmap_valueforkey(key, Varptr _root)
 	End Method
 	
-	Method Remove( key:Object )
+	Method Remove:Int( key:Object )
 ?ngcmod
 		_modCount :+ 1
 ?
@@ -139,7 +139,7 @@ Type TObjectNode
 		Return bmx_map_objectmap_value(_nodePtr)
 	End Method
 
-	Method HasNext()
+	Method HasNext:Int()
 		Return bmx_map_objectmap_hasnext(_nodePtr, _root)
 	End Method
 	
@@ -156,7 +156,7 @@ Type TObjectNode
 End Type
 
 Type TObjectNodeEnumerator
-	Method HasNext()
+	Method HasNext:Int()
 		Local has:Int = _node.HasNext()
 		If Not has Then
 			_map = Null
@@ -213,7 +213,7 @@ Type TObjectMapEnumerator
 End Type
 
 Type TObjectEmptyEnumerator Extends TObjectNodeEnumerator
-	Method HasNext() Override
+	Method HasNext:Int() Override
 		_map = Null
 		Return False
 	End Method

+ 6 - 6
map.mod/ptrmap.bmx

@@ -1,4 +1,4 @@
-Strict
+SuperStrict
 
 
 Extern
@@ -42,7 +42,7 @@ Type TPtrMap
 	bbdoc: Checks if the map is empty.
 	about: #True if @map is empty, otherwise #False.
 	End Rem
-	Method IsEmpty()
+	Method IsEmpty:Int()
 		Return bmx_map_ptrmap_isempty(Varptr _root)
 	End Method
 	
@@ -78,7 +78,7 @@ Type TPtrMap
 	bbdoc: Remove a key/value pair from the map.
 	returns: #True if @key was removed, or #False otherwise.
 	End Rem
-	Method Remove( key:Byte Ptr )
+	Method Remove:Int( key:Byte Ptr )
 ?ngcmod
 		_modCount :+ 1
 ?
@@ -201,7 +201,7 @@ Type TPtrNode
 		Return bmx_map_ptrmap_value(_nodePtr)
 	End Method
 
-	Method HasNext()
+	Method HasNext:Int()
 		Return bmx_map_ptrmap_hasnext(_nodePtr, _root)
 	End Method
 	
@@ -229,7 +229,7 @@ Type TPtrKey
 End Type
 
 Type TPtrNodeEnumerator
-	Method HasNext()
+	Method HasNext:Int()
 		Local has:Int = _node.HasNext()
 		If Not has Then
 			_map = Null
@@ -288,7 +288,7 @@ Type TPtrMapEnumerator
 End Type
 
 Type TPtrEmptyEnumerator Extends TPtrNodeEnumerator
-	Method HasNext() Override
+	Method HasNext:Int() Override
 		_map = Null
 		Return False
 	End Method

+ 6 - 6
map.mod/stringmap.bmx

@@ -1,4 +1,4 @@
-Strict
+SuperStrict
 
 
 Extern
@@ -42,7 +42,7 @@ Type TStringMap
 	bbdoc: Checks if the map is empty.
 	about: #True if @map is empty, otherwise #False.
 	End Rem
-	Method IsEmpty()
+	Method IsEmpty:Int()
 		Return bmx_map_stringmap_isempty(Varptr _root)
 	End Method
 	
@@ -78,7 +78,7 @@ Type TStringMap
 	bbdoc: Remove a key/value pair from the map.
 	returns: #True if @key was removed, or #False otherwise.
 	End Rem
-	Method Remove( key:String )
+	Method Remove:Int( key:String )
 ?ngcmod
 		_modCount :+ 1
 ?
@@ -201,7 +201,7 @@ Type TStringNode
 		Return bmx_map_stringmap_value(_nodePtr)
 	End Method
 
-	Method HasNext()
+	Method HasNext:Int()
 		Return bmx_map_stringmap_hasnext(_nodePtr, _root)
 	End Method
 	
@@ -218,7 +218,7 @@ Type TStringNode
 End Type
 
 Type TStringNodeEnumerator
-	Method HasNext()
+	Method HasNext:Int()
 		Local has:Int = _node.HasNext()
 		If Not has Then
 			_map = Null
@@ -275,7 +275,7 @@ Type TStringMapEnumerator
 End Type
 
 Type TStringEmptyEnumerator Extends TStringNodeEnumerator
-	Method HasNext() Override
+	Method HasNext:Int() Override
 		_map = Null
 		Return False
 	End Method