Hi all,
First, does anyone know if anyone has created a linked-list library for X2? I just created a very simple one and am quite willing to share, but I don't want to submit a duplicate if there's already something more thoroughly proven out there.
Second, can anyone recommend a good file-hosting site? Thanks.
Two questions
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 193
- Joined: Fri, 30. Jul 04, 22:47
Are the resize operations for the built-in array optimized (no, seriously, I don't know)?
A linked list allows me to insert a node in the middle of the list. A built-in array requires that I first resize the array to accommodate the elements that I'm adding and then shift each element over from the point where I want to add my new elements.
The only requirement with a linked-list is that I traverse it to the point where I'd like to insert the elements first.
Of course, there's script invocation overhead and some potential threading issues if the same linked list is manipulated by two separate processes.
Plus some tasks lend themselves to stack-solutions (like writing an RPN in X2). But in all seriousness, I have found it useful for my tasks.
A linked list allows me to insert a node in the middle of the list. A built-in array requires that I first resize the array to accommodate the elements that I'm adding and then shift each element over from the point where I want to add my new elements.
The only requirement with a linked-list is that I traverse it to the point where I'd like to insert the elements first.
Of course, there's script invocation overhead and some potential threading issues if the same linked list is manipulated by two separate processes.
Plus some tasks lend themselves to stack-solutions (like writing an RPN in X2). But in all seriousness, I have found it useful for my tasks.
-
- Moderator (Script&Mod)
- Posts: 22438
- Joined: Sun, 14. Nov 04, 23:26
i think ur thinking of arrays in other languages like C.
in X scripting an array isn't like in C, its basically a linked list, you can remove and insert entries anywhere in the array. As well as append (push_back) and remove (pop_back) entries.
u dont need to resizes the array or even move entries around in the array.
and it is optimized simply coz built in commands are always faster than scripted commands.
coz scripting languages are inheritically slow, but the built in commands are already compiled and run at full speed
in X scripting an array isn't like in C, its basically a linked list, you can remove and insert entries anywhere in the array. As well as append (push_back) and remove (pop_back) entries.
u dont need to resizes the array or even move entries around in the array.
and it is optimized simply coz built in commands are always faster than scripted commands.
coz scripting languages are inheritically slow, but the built in commands are already compiled and run at full speed