Page 2 of 2
Posted: Wed Aug 29, 2007 6:01 pm
by nco2k
@Trond
why should i write a loop when i can use SelectElement(), which will do the same?! like fred said, its a convenience function. the only problem is, that it doesnt search position dependant, thats all.
c ya,
nco2k
Posted: Wed Aug 29, 2007 7:59 pm
by Trond
nco2k wrote:@Trond
why should i write a loop when i can use SelectElement(), which will do the same?! like fred said, its a convenience function. the only problem is, that it doesnt search position dependant, thats all.
c ya,
nco2k
I don't understand you. You're NOT SUPPOSED TO EVER index a list item by its position. That's the point of lists, they are position independent, so that items can be added and deleted in the middle of the list.
-> If you need to store a reference to a specific item it is nonsense to use the number, since it will change. Instead use the address of the element and ChangeCurrentElement().
-> If you don't need to store a reference to specific item you don't need SelectElement() at all.
Where's the problem? The problem is that a perfectly sensible and fast function exists and does what is needed, but people prefer to not use it and instead use a function that is totally unsuitable for the task. How that can be fixed I don't know.
Posted: Wed Aug 29, 2007 8:12 pm
by Ollivier
@nco2k
I discover your really good code.
But I don't understand what's happening when I replace 'DisableDebugger' with 'EnableDebugger'.
Posted: Fri Aug 31, 2007 5:23 pm
by DoubleDutch
nco2k: I agree that an optimised position dependant version would work best.
The current position would only be invalid if there has been a clear list, select element, or an insert item or delete item before the current position. Even then it could easily be updated to take this into account.
Posted: Wed Sep 12, 2007 9:01 pm
by freak
I implemented an improved version that takes the current position into account
Can you guys test it to see if it works as expected ?
http://freak.purearea.net/v4/LinkedList
As Trond and others noted though, if speed is important then Lists + SelectElement() are the wrong solution.
The improvement increased the speed for random access by a constant factor only (about 3x faster on average),
it does in no way reduce the complexity of the underlying algorithmic problem.
So if you really want speed (especially for large numbers of elements), use an array.
Posted: Wed Sep 12, 2007 9:32 pm
by DoubleDutch
I've just tested it with ReportBuilder, seems to work without problems.
Is there a list of all the slight beta updates anywhere (rather than searching the forums)?
Posted: Wed Sep 12, 2007 10:13 pm
by rsts
freak wrote:I implemented an improved version that takes the current position into account
Can you guys test it to see if it works as expected ?
http://freak.purearea.net/v4/LinkedList
As Trond and others noted though, if speed is important then Lists + SelectElement() are the wrong solution.
The improvement increased the speed for random access by a constant factor only (about 3x faster on average),
it does in no way reduce the complexity of the underlying algorithmic problem.
So if you really want speed (especially for large numbers of elements), use an array.
Is there an extension we can apply to that url? It just opens in my browser as text and gibberish. What kind of file is it?
cheers
Posted: Wed Sep 12, 2007 10:15 pm
by netmaestro
rightclick the link and "save target as", you'll probably have to remove a .txt extension when it lands on your drive. Put it in the \PureBasic\Libraries folder and restart the compiler, should be good to go.
Posted: Wed Sep 12, 2007 10:20 pm
by rsts
Thanks, netmaestro.
I had already saved it (with a txt extension), so I'm halfway there
cheers
edit.
Haven't tested it for speed, but my linked list functions seem to work just fine.
Posted: Thu Sep 13, 2007 11:24 am
by pdwyer

SQLite has an option to create an in-memory database which runs very fast (for a database). I wonder how it stacks up in this case.
http://www.purebasic.fr/english/viewtop ... ght=sqlite
It may be a little slower to load but I suspect a lot faster to read from and as a big bonus, you get all the power and features of SQL commands so your sorting and searching of subsets would be great.
Not sure if it would help you with what you are doing but it might be worth a try
...just a thought
Posted: Tue Oct 16, 2007 7:46 pm
by nco2k
@freak
thanks for adding this one. i did a short speed test and its
extremly fast now!
no bugs found so far... great work!
c ya,
nco2k