How do I use TMap?

BlitzMax Forums/BlitzMax Beginners Area/How do I use TMap?

GMan many thanks, this really helped!

Here is the simplified version of TMap. I use Strings both as objects and Strings. A bit easier to read. Otherwise it's the same as above.

'Initiate TMap
Global Map:TMap = New TMap

' A D D
Key$ = "Card on Hand"
Map.Insert( Key , "Dimond" )
Map.Insert( Key , "Harts" )'Will overwrite "Dimond"

Key$ = "Marker1"
Map.Insert( Key , "Not Blue" )

Key$ = "Marker2"
Map.Insert( Key , "Red" )

Key$ = "Marker1"
Map.Insert( Key , "Blue" )' Write 'Blue' to Node 'Marker1'

' F I N D
Key$ = "Card on Hand"' Yes the key is caSe SensItivE
If Map.FindNode( Key ) 		Print "Key Found" Else Print "Key NOT Found"

' F I N D   A L L   K E Y S
Print "------ All Keys in Map -------"
Local n=0
For S$ = EachIn Map.Keys()
	n:+1
	Print n+". Key in Map: "+S	
Next

' F I N D   A L L   O B J E C T S

Print "------ All Objects in Map -------"
n=0
For S$ = EachIn Map.Values()
	n:+1
	Print n+". Object in Map: "+S
Next

' F I N D   A L L   N O D E S

Print "------ All Nodes in Map -------"
n=0
For Node:TNode = EachIn Map
	n:+1
	Print n+". Key  : "+Node.Key().ToString()
	Print n+". Value: "+Node.Value().ToString()
Next


' R E M O V E

'Remove key
Key$ = "Marker1"
Map.Remove( Key )

'Remove A Key based on the Object/Value
ObjectInQuestion$ = "Red"
For Node:TNode = EachIn Map
	If Node.Value() = ObjectInQuestion$ Node.Remove()
Next