Not a bug, but lists are nearly useless because of speed
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.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
-> 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.
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
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.
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.
quidquid Latine dictum sit altum videtur
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
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?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.
cheers
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada


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
Paul Dwyer
“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein