Dumping key/value pairs from TMap

BlitzMax Forums/BlitzMax Programming/Dumping key/value pairs from TMap

Maybe this helps you:

Type TTest
	Field ID:Int
	Field Name:String
	
	Function Create:TTest(ID:Int , Name:String)
		Local T:TTest = New TTest
		T.ID = ID
		T.Name = Name
		Return T
	End Function
	
	Method ToString:String()
		Return ID + " , " + Name
	End Method
	
	
End Type

Local Map:TMap = New TMap

Map.Insert("test1" , TTest.Create(1 , "Test1") )
Map.Insert("test2" , TTest.Create(2 , "Test2") )
Map.Insert("test3" , TTest.Create(3 , "Test3") )
Map.Insert("test4" , TTest.Create(4 , "Test4") )
Map.Insert("test5" , TTest.Create(5 , "Test5") )

'Getting all Keys

For Local S:String = EachIn Map.Keys()
	Print S
Next


'Getting All Values

For Local T:TTest = EachIn MAp.Values() 
	Print T.ToString()
Next

'Receiving The Node for 1 special Key

Local N:TNode = Map._FindNode("test3")

Print String(N._Key) + " : " + TTest(N._Value).ToString()