I have a folder array that contains up to +1.000.000 entries.
Dim folderStack() as FolderItem
Now I need to remove X entries at the start and Y entries at the end.
Cutting the end isn’t difficult:
If I need to cut the last 5.000 and total entries is 10.000)
For removing entries at the start, is a bit more work. You need to copy the ones you want to keep to another array and then copy it back.
When there are a lot of entries, this is slow when you have a lot of entries.
Anyone has a better way doing this?
FWW with Swift you have ArraySlice which works incredible fast (even for more than 1.000.000 entries is <0.1s). I don’t think Xojo has a similar
Another thought: how about using Array.SortWith() https://documentation.xojo.com/api/language/sort.htmlWith and sort the array so the to-be-deleted items are now at the end of the array, and then use Redim() to truncate the array? This might be faster (it might also be much, much slower).
sub FastSliceArray(extends a() as folderItem, startIndex as integer, endIndex as integer)
dim i as integer = 0
for j as integer = startIndex to endIndex
a(i) = a(j) ' shift item
i = i + 1 ' remember index of last shifted item
redim a(i-1) ' truncate