|
|
#31 |
|
Panda > You
|
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 Last edited by PandaMine : 12-14-2008 at 09:29 AM. |
|
|
|
| Sponsored Links - Login to hide this ad! |
|
|
|
|
#32 |
|
I blink, therefore I am.
Join Date: Sep 2006
Posts: 1,812
![]() ![]() ![]()
|
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.
__________________ |
|
|
|
|
|
#33 |
|
Panda > You
|
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 |
|
|
|
|
|
#34 |
|
I blink, therefore I am.
Join Date: Sep 2006
Posts: 1,812
![]() ![]() ![]()
|
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 02:19 AM. |
|
|
|
|
|
#35 |
|
Panda > You
|
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. |
|
|
|
|
|
#36 | |
|
I blink, therefore I am.
Join Date: Sep 2006
Posts: 1,812
![]() ![]() ![]()
|
Quote:
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. |
|
|
|
|
|
|
#37 |
|
In Flames
Join Date: Jan 2006
Posts: 1,153
|
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) |
|
|
|
|
|
#38 | |
|
I blink, therefore I am.
Join Date: Sep 2006
Posts: 1,812
![]() ![]() ![]()
|
Quote:
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. |
|
|
|
|
|
|
#39 |
|
Panda > You
|
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. Last edited by PandaMine : 12-15-2008 at 10:24 PM. |
|
|
|
|
|
#40 |
|
Procrastination Incarnate
Development Director
|
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.
__________________ |
|
|
|
|
|
#41 |
|
User
Join Date: Jan 2007
Posts: 528
![]()
|
Does this work like this:
LINK=[][][][] lllllllll LINK=[][][][] lllllllll LINK=[][][][] lllllllll LINK=[][][][] lllllllll LINK=[][][][] ??? |
|
|
|
|
|
#42 | |
|
I blink, therefore I am.
Join Date: Sep 2006
Posts: 1,812
![]() ![]() ![]()
|
Quote:
Im not sure what you mean by that, but as quoted from the script: 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() |
|
|
|
|
|
|
#43 |
|
User
Join Date: Jan 2007
Posts: 528
![]()
|
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 06:13 AM. |
|
|
|
|
|
#44 |
|
I blink, therefore I am.
Join Date: Sep 2006
Posts: 1,812
![]() ![]() ![]()
|
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 06:25 AM. |
|
|
|
|
|
#45 |
|
Moderator
Code Moderator
Join Date: Feb 2006
Posts: 1,405
![]() ![]() ![]()
|
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.
__________________ |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
|
Donate |