Arrays of TLists Storing Data for Tiles in Rpg ?

BlitzMax Forums/BlitzMax Programming/Arrays of TLists Storing Data for Tiles in Rpg ?

Ive been working on a rpg battle system for some time now while waiting for the 3dmodule but finally I am at point where the engine needs a visual touch for tweaking and timing.
I have settled for a subdivision method for levels in a structure as follows

Map>Continent>Country>Region>City>Area>Sector>Grid

Im going to use linked lists in a array format so i can move ,remove ,create areas and add them to the list at any time during the game

here is the test code

Global AreaList:TList=CreateList()


Type Area
	Field Total_Sect
	Field Sect_X
	Field Sect_Y
	Field Sector_List:TList[]
	
	Function Create:Area(_TS,_SX,_SY)
		Temp:Area=New Area
			Temp.Total_Sect=_TS
			Temp.Sect_X=_SX
			Temp.Sect_Y=_SY
			ListAddLast Arealist,temp
			
			Temp.Set_List_Array(_SX,_SY)
	End Function
	
		Method Set_List_Array(_SX,_SY)
			Sector_List=Sector_List[.._SX]
				For X=0 To _SX-1
					Sector_List:TList[x]=CreateList()
						For Y=0 To _SY-1
							Local Newsect:Sector=Sector.create(Y)
							ListAddLast Sector_List[x],Newsect
						Next
				Next 
		End Method
	
		Method Print_Lists(X)
		
			For Temp:Sector=EachIn Sector_list[X]
				Times:+1
				Print Temp.ID+1
			Next
		End Method
End Type



Type Sector
	Field ID
	
	Function Create:Sector(_SY)
		Temp:Sector=New Sector
			Temp.ID=_SY
		Return Temp
	End Function
End Type

Area.create(27,3,9)


For Test:Area=EachIn Arealist
Areas:+1
Print "AREA  ="+AREAS
For x=0 To test.Sect_X-1
Sectx:+1
Print "SECT_X="+Sectx

test.Print_Lists(X)
Print ""
Next

Next



Just wondering if anybody knows of a better way of doing this code or a faster method

your main hangup is in the creation of the lists, if I do the following:
Local Start:Int = MilliSecs()
Area.create(27,100,2000)
Print MilliSecs()-Start
it takes about 6900ms to complete this step.

adding flushmem inside the creation loop reduces this to 51ms
		Method Set_List_Array(_SX,_SY)
			Sector_List=Sector_List[.._SX]
				For X=0 To _SX-1
					Sector_List:TList[x]=CreateList()
						For Y=0 To _SY-1
							Local Newsect:Sector=Sector.create(Y)
							ListAddLast Sector_List[x],Newsect
							
						Next
					FlushMem '<!----- Add flushmem here
				Next 
		End Method


Thanks m8 that looks like it will do the trick :)

Until auto flushmem in the next update.