Skip to main content

News

Topic: [Script] LinkedList (Read 2695 times) previous topic - next 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^^

[gist]5373204[/gist]
  • Last Edit: April 12, 2013, 12:22:42 pm by Metallix

  • alpha123
  • [*]
  • Verified
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
  • miniSphere 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. :)
miniSphere 4.8.4 - Cell compiler - SSj debugger
Forum Thread | GitHub Repo

  • 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 ^^