Hi to All. Maybe it is a silly question, but I don't see a way to write an array of floats to the disk. The File object doesn't contain a method for this. The need for using low level functions is related to efficiency. I'll describe the problem first, to explain from where the need of low level I/O functions arises.
I have a map with objects of the folllowing type:
I save/load this maps with RandomAccessFile.
The problem arises because vertexArray is huge and the App takes minutes to save/load various tens of Mb, most of them floats contained in the vertexArray of each vertexData object. My idea was to use FILE object, but It only allows to write/read bytes arrays, Lists, Maps etc, and of course, it doesn't manage the whole Map of vertexData objects...
Thanks in advance for any hint
I have a map with objects of the folllowing type:
B4X:
Type VertexData(changed As Boolean, vertexList As List, vertexArray() As Float, beginIndices(4) As Int, endIndices(4) As Int)
B4X:
'
' mData is a Map with key "color" and value a VertexData object
'
'
private Sub UtSave(raf As RandomAccessFile,mData As Map,pos As Long) As Long
raf.WriteInt(mData.Size,pos) ' cannot use directly raf.WriteObject(mData,true,pos); App is compiled but crashes saying that mData contains "primitives"
pos=pos+4 ' so I save the map size and each component
For Each color As Int In mData.Keys '
raf.WriteInt(color,pos)
pos=pos+4
raf.WriteObject(mData.Get(color),True,pos) ' mData.Get(color) is a VertexData object
pos=raf.CurrentPosition
Next
return pos
end sub
'' calling function
'
pos=UtSave(raf,ldata.pointMap,pos)
'
The problem arises because vertexArray is huge and the App takes minutes to save/load various tens of Mb, most of them floats contained in the vertexArray of each vertexData object. My idea was to use FILE object, but It only allows to write/read bytes arrays, Lists, Maps etc, and of course, it doesn't manage the whole Map of vertexData objects...
Thanks in advance for any hint