|
tomata Potato
Registered User
Join date: 10 Mar 2006
Posts: 4
|
03-12-2006 20:57
Is there any efficient way to traverse a list?
If you do something like:
list a_big_list = [many many things];
integer iMax = llListGetSize(a_big_list);
for (int i = 0; i < iMax; ++i) { llWhisper(llListGetString(a_big_list, i)); }
Is this actually a n^2 algorythm? I would suppose that llListGet*() methods traverse the list from the beginning since lists are actually linked lists?
|
|
Holden Lobo
Registered User
Join date: 21 Dec 2005
Posts: 1
|
03-12-2006 22:18
looks like order n to me. why did you say n^2?
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-12-2006 22:55
It's my understanding (which could, of course, be wrong), that llList2xxx functions do indeed traverse the list from the beginning. So that's O(n) for each function call, which makes that loop O(n^2).
|
|
tomata Potato
Registered User
Join date: 10 Mar 2006
Posts: 4
|
03-13-2006 15:08
I think LSL is in dire need to improve the datastructure capabilities. The list does not give us any abilities to even create new datastructures. Like, how would you make a Hashtable? Is there a vote on this feature?
Of course, the other stuff in LSL is totally awesome, IMO. I can actually get things done, as opposed to working with OpenGL directly. Ok, you OpenGL gurus, start flaming! Haha.
|