wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 12-14-2008, 10:28 AM   #31
PandaMine
Panda > You
 
PandaMine's Avatar
 
Join Date: May 2006
Posts: 500

Submissions (4)

PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)

Send a message via MSN to PandaMine
Default

You going to implement trees next :p

Using data structures should be second knowledge, in my opinion this should be a tutorial to teach people about data strcutures

Also is there any reason you are storing the previous node, by convention linked list should be a single direction
__________________
PandaMine's Creations:

Last edited by PandaMine : 12-14-2008 at 10:29 AM.
PandaMine is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 12-14-2008, 04:52 PM   #32
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)

Default

Linked lists can also be doubly-linked as well as circularly-linked (the last node's .next returns the first node and the first node's .prev returns the last node). Each type has their own special properties. A doubly linked list take a bit more operations for creation/destruction but allow for easy insert without having to loop from the front of the list.
__________________
Ammorth is offline   Reply With Quote
Old 12-15-2008, 12:13 AM   #33
PandaMine
Panda > You
 
PandaMine's Avatar
 
Join Date: May 2006
Posts: 500

Submissions (4)

PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)

Send a message via MSN to PandaMine
Default

I know, but that is precisely the point

For example, I may only want the generic linked list that finishes, and I actually do need it to finish and not run around in circles forever. On the other hand someone may want a linked list that does go around in circles and not run forever

This is why I am saying this should be a tutorial and not really in the scripts section, people should learn why and when to use certain data structures. For example you're implementation is a terminating doubly linked list, however someone may want to have a circular linked list and they may have no reason as to why the list should be in 2 directions instead of one, which can slightly decrease performance as more variables need to be set every time you insert a value into the list or delete a value
__________________
PandaMine's Creations:
PandaMine is offline   Reply With Quote
Old 12-15-2008, 03:18 AM   #34
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)

Default

If a mod agrees, I can create both the singular linked list as well as the circularly linked lists and then include them as seperate libraries within this script. (Aka, LinkedListS, LinkedListD, LinkedListC )

I'm not sure if its practical though.
__________________

Last edited by Ammorth : 12-15-2008 at 03:19 AM.
Ammorth is offline   Reply With Quote
Old 12-15-2008, 11:11 AM   #35
PandaMine
Panda > You
 
PandaMine's Avatar
 
Join Date: May 2006
Posts: 500

Submissions (4)

PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)

Send a message via MSN to PandaMine
Default

Look all Im trying to say is I don't see much point in these "scripts"

If a person finds a situation in which they need to use a linked list, 99% of the time that person will also know how to program a linked list. This is why I believe this should be a tutorial to teach people that don't know about linked lists (as well as stacks and trees and heaps and whatnot) but more importantly why and in which situation they should use them.
__________________
PandaMine's Creations:
PandaMine is offline   Reply With Quote
Old 12-15-2008, 05:10 PM   #36
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)

Default

Quote:
Originally Posted by PandaMine
Look all Im trying to say is I don't see much point in these "scripts"

If a person finds a situation in which they need to use a linked list, 99% of the time that person will also know how to program a linked list. This is why I believe this should be a tutorial to teach people that don't know about linked lists (as well as stacks and trees and heaps and whatnot) but more importantly why and in which situation they should use them.

Is thats the belief, then why do we have any type of resource to begin with? Everything should be converted to tutorials (including all models) and then someone can make it on their own when they need it.

The point is, this saves people time in having to write it by themselves. Sure, it may not be a huge saving, but every bit helps when trying to work map-making into everyday life.
__________________
Ammorth is offline   Reply With Quote
Old 12-15-2008, 05:35 PM   #37
akolyt0r
In Flames
 
akolyt0r's Avatar
 
Join Date: Jan 2006
Posts: 1,153

Submissions (3)

akolyt0r has a spectacular aura about (120)

Default

eh ...its much easier to import an model, than to make one ...

compared to that, the time you need to understand something like link lists (if you dont have a clue of programming) is nearly the same you would need to do your own system :> (ok maybe its like 2:1, but import a model : make your own model... its like 20:1)

so you example is really bad.

but ressources like this are still valueable for those guys who already now stuff like linked lists (maybe from other programming languages), but dont have much time to do their own system (also it wouldnt be a problem to those probably)
akolyt0r is offline   Reply With Quote
Old 12-15-2008, 06:23 PM   #38
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)

Default

Quote:
Originally Posted by akolyt0r
eh ...its much easier to import an model, than to make one ...

compared to that, the time you need to understand something like link lists (if you dont have a clue of programming) is nearly the same you would need to do your own system :> (ok maybe its like 2:1, but import a model : make your own model... its like 20:1)

so you example is really bad.

I agree, but with all the "useless" script resources out there, why suddenly is this one being shot down? I wasn't the first to create a LinkedLists script either. Why wasn't iNfraNe shot-down before me?

The point I'm trying to make is if you don't find this useful, don't use it. I know of 2 people already who are using this script in their maps/systems and they don't seem to complain. I personally am not going to use this for every future thing I make, but it can come in handy instead of always having to re-write it for every need. I am currently using it for a couple of things, and it's nice to have a system that is tested and true while developing new scripts. The worst thing is when you get a bug in a new system and spend hours debugging it, only to find it was being caused by the other system it required.
__________________
Ammorth is offline   Reply With Quote
Old 12-15-2008, 11:23 PM   #39
PandaMine
Panda > You
 
PandaMine's Avatar
 
Join Date: May 2006
Posts: 500

Submissions (4)

PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)PandaMine has a spectacular aura about (96)

Send a message via MSN to PandaMine
Default

Im not trying to shoot you down (its just that I just came online and this is the first thread in the system).

I just believe that scripts should be for functions or group of functions that are difficult to code or come up with or something that someone came up with that is new and really revolutionizes stuff.

Im not saying that people won't use it, however you will probably find a hell of a let less people using the system then you would expect. Linked lists is like the simplest data structure in programming, and if someone knows a situation they need to use one, they will know how to program it. It only takes like 20 lines to write a linked list ADT, its not like its a whole caster system or something like that.

Model's is a BAD comparison, because it can take up to weeks to make a model. I can write a linked list system in prob's 10 minutes, its really not that hard. That is in my belief why this should be a tutorial, so you actually teach people about linked lists, because when they code it themselves they will actually know how to use it and the situations when to use it.

The only exception would be if there is some bug in JASS that does not allow you to make a linked list as you would normally do in other languages, and that's not really the case (well there was one exception, and that was abusing locations for linked lists which is what Vex's caster system did before vJASS, and that was an unconventional way of doing linked lists)

Infrane probably won't get shot down, there is nothing bad about about uploading linked lists, its just a waste of time really.
__________________
PandaMine's Creations:

Last edited by PandaMine : 12-15-2008 at 11:24 PM.
PandaMine is offline   Reply With Quote
Old 12-16-2008, 01:07 AM   #40
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,085

Submissions (19)

Anitarf has a brilliant future (888)Anitarf has a brilliant future (888)Anitarf has a brilliant future (888)Anitarf has a brilliant future (888)Anitarf has a brilliant future (888)Anitarf has a brilliant future (888)Anitarf has a brilliant future (888)Anitarf has a brilliant future (888)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Frankly I'm getting tired of inlining linked lists code into every other spell or system I make, I could really use (and likely will) this library.
__________________
Anitarf is offline   Reply With Quote
Old 01-23-2009, 05:06 AM   #41
fX_
User
 
fX_'s Avatar
 
Join Date: Jan 2007
Posts: 528

Submissions (2)

fX_ will become famous soon enough (38)fX_ will become famous soon enough (38)

Default

Does this work like this:

LINK=[][][][]
lllllllll
LINK=[][][][]
lllllllll
LINK=[][][][]
lllllllll
LINK=[][][][]
lllllllll
LINK=[][][][]

???
fX_ is offline   Reply With Quote
Old 01-23-2009, 05:49 AM   #42
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)

Default

Quote:
Originally Posted by fX_
Does this work like this:

LINK=[][][][]
lllllllll
LINK=[][][][]
lllllllll
LINK=[][][][]
lllllllll
LINK=[][][][]
lllllllll
LINK=[][][][]

???

Im not sure what you mean by that, but as quoted from the script:
Collapse JASS:
//  Usage:
//      - Create a new empty list with List.create()
//      - Add new data to the front of the list with Link.create(list, data)
//      - Add new data to the back of the list with Link.createLast(list, data)
//      - Insert new data before a link with link.insertBefore(data)
//      - Insert new data after a link with link.insert(data)
//      - Get the next and previous links with link.next and link.prev
//      - Get the list a link belongs to with link.parent
//      - Get the first or last link in a list with list.first or list.last
//      - Get the size of a list with list.size
//      - Get the link which contains data with list.Search(data)
//      - Remove a link with link.destroy()
//      - Destroy the entire list (including links) with list.destroy()  
__________________
Ammorth is offline   Reply With Quote
Old 01-23-2009, 07:12 AM   #43
fX_
User
 
fX_'s Avatar
 
Join Date: Jan 2007
Posts: 528

Submissions (2)

fX_ will become famous soon enough (38)fX_ will become famous soon enough (38)

Default

What is a 'link' and what is a 'list'? The latter I think is an array of data:

data1
data2
data3
data4

Now, what is a 'link'?

Last edited by fX_ : 01-23-2009 at 07:13 AM.
fX_ is offline   Reply With Quote
Old 01-23-2009, 07:23 AM   #44
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)

Default

The link is where the data is stored and the List is the header to the link.

[list] [Link = data1] [Link = data2] [Link = data3] ... [Link = dataN]

Combining Links together in a list while adding a header to the front (for some operations and to make sure you always have an index to the list even if you change the links inside) you get a LinkedList.

They are not as useful in-place of arrays as they are useful for storing data in relations to each other in a way you can add and remove efficiently (O(1) complexity).
__________________

Last edited by Ammorth : 01-23-2009 at 07:25 AM.
Ammorth is offline   Reply With Quote
Old 02-26-2009, 01:49 AM   #45
PipeDream
Moderator
 
PipeDream's Avatar


Code Moderator
 
Join Date: Feb 2006
Posts: 1,405

Submissions (6)

PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)

Default

Out of curiousity, did you have an application in mind when you extended from single to double linked? I'm guessing an STL style deque but again I don't know what you'd use it for.
__________________
PipeDream is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 06:49 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services