[Tmap is B-tree?]

BlitzMax Forums/BlitzMax Beginners Area/[Tmap is B-tree?]

Thanks for the answer, but I want to know if there is a Count() method like in List, or I need to iterate in the map via FOR..EACHIN


There's no in-built counting, but you could add your own:


Type TExMap Extends TMap
	
	Field count:Int
	
	Method Insert( key:Object,value:Object )
		Super.Insert(key, value)
		Count:+1
	End Method
	
	Method Remove( key:Object )
		Super.Remove(key)
		Count:-1
	End Method
	
	Method Clear()
		Super.Clear()
		Count = 0
	End Method
End Type

Global myMap:TExMap = New TExMap

myMap.Insert("test1", "value1")
myMap.Insert("test2", "value2")
myMap.Insert("test3", "value3")
myMap.Insert("test4", "value4")
myMap.Insert("test5", "value5")
myMap.Insert("test6", "value6")
Print myMap.count
myMap.Remove("test4")
Print myMap.count


*EDIT*
Spent too long writing that :)