Skip to main content

News

Topic: [Script] LinkedList (Read 8061 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
[Script] LinkedList
The following script is a small helper that can be useful when you deal with lists or arrays and change the content often. It implements a super simple linked list.
This is a very simple script and some of you may already have a similar utility script. But it appeared that I use this script already very frequently in my scripts and I want to post some other scripts here soon that requires this script.

It is maybe also good to explain the concept of a linked list to beginners.

Features:

  • Can be a bit faster than the use of array in some situations ( ie: queues, deleting of many random elements )

  • Changing the content of the list while iterating over it is easier/safer,  compared to a solution using an array



Usage: see script :)

Note: This is tested in TurboSphere. I am not sure if Sphere1.5 supports the null keyword... but if not it is maybe easy to emulate^^

  • Last Edit: April 12, 2013, 12:22:42 pm by Metallix

Re: [Script] LinkedList
Reply #1

Note: This is tested in TurboSphere. I am not sure if Sphere1.5 supports the null keyword... but if not it is maybe easy to emulate^^

JavaScript has had a null keyword since the very first versions. Despite its age, the version of SpiderMonkey in Sphere 1.5 definitely supports it.

Re: [Script] LinkedList
Reply #2
Ok, for some reason I thought sphere does not support it. I always avoided to use it in my Sphere code xD

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: [Script] LinkedList
Reply #3
The Sphere editor doesn't highlight it for some reason. I was wary of it at first for the same reason, until I researched JS and found out it was a standard part of the language. Then I just felt dumb. :)
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: [Script] LinkedList
Reply #4
Yea, null exists; I've used it all over my PSG and YM2612 scripts with no problem.

Re: [Script] LinkedList
Reply #5
Had some time to checkout what gist is :) -> Updated above ^^