• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Has anybody written a linkedlist?

Status
Not open for further replies.
Level 1
Joined
May 28, 2011
Messages
4
I am currently in need of a linkedlist, but I don't want to have to write and test it if someone has already made one :>
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Isn't a linked list a... kind of method to store stuff in?

Like this:
JASS:
// This sets up the variables
value[0] = "a"
value[1] = "b"
value[2] = "c"
value[3] = "d"
value[4] = "e"

next[0] = 2
previous[0] = 4

next[2] = 4
previous[2] = 0

next[4] = 0
previous[4] = 2

JASS:
// This prints the values
local integer i = next[0]
loop
    exitwhen i == 0 // Ends when back at the beginning (the 'head')

    call BJDebugMsg(value[i]) // Prints "a" -> "c" -> "e"
    set i = next[i]
endloop

JASS:
// This will remove value 2 from the previous linked list
set next[previous[2]]=next[2]
set previous[next[2]]=previous[2]

// next[0] = next[2] --> next[0] = 4
// previous[4] = previous[2] --> previous[4] = 0
// It forgets about the value "2" completely
// The function above will now print "a" -> "e"

JASS:
// This will add value 1 to the list
set next[0] = 1
set previous[2] = 1
set next[1] = 2
set previous[1] = 0

// The print-function will now say "abce"

According to my definition, that is a linked list.
So unless you can be more precise, there's your answer :p
 
Level 1
Joined
May 28, 2011
Messages
4
Its a fairly commen programming data structure, the idea is you have nodes which are "linked" to each other, The advantage is you can add to the list in O(1) time, and since I don't need to look at specific indexes the O(n) search time won't be a problem.

I think I didn't make myself too clear, what I was looking for were a vjass library with everything made.
 
Last edited by a moderator:
Level 18
Joined
Jan 21, 2006
Messages
2,552
Just typed this up now, seems to work:

JASS:
library LinkedListLib
struct LinkedListNode
	integer dataTag = 0

	thistype next   = 0
	thistype prev   = 0
    
    method onDestroy takes nothing returns nothing
        set dataTag = 0
        set next = 0
        set prev = 0
    endmethod
    
	static method create takes integer dataTag, thistype next returns thistype
		local thistype node = allocate()
		set node.dataTag = dataTag
		
		if next != 0 then
			set node.next = next
			set node.prev = next.prev
			
			if node.prev != 0 then
				set node.prev.next = node
			endif
			set node.next.prev = node
		else
			set node.next = 0
			set node.prev = 0
		endif	

		return node
	endmethod
endstruct

struct LinkedList
	LinkedListNode	top
	LinkedListNode	bot
    
    integer size = 0

    // Returns the size of the linked list.
    method getSize takes nothing returns integer
        return size
    endmethod
    
    // Clean linked list elements
    method onDestroy takes nothing returns nothing
        local LinkedListNode n = top
        local LinkedListNode t
        loop
            exitwhen n == 0
            set t = n
            set n = n.next
            call t.destroy()
        endloop
    endmethod
    
    // Returns the extracted 'top' element.
    method extractTop takes nothing returns integer
        local LinkedListNode t
        local integer tag = 0
        if not isEmpty() then
            set t = top
            set tag = t.dataTag
            set top = top.next
            call t.destroy()
            set size = size - 1
        endif
        return tag
    endmethod
    
    // Returns the extracted 'bot' element.
    method extractBot takes nothing returns integer
        local LinkedListNode b 
        local integer tag = 0
        if not isEmpty() then
            set b = bot
            set tag = b.dataTag
            set bot = bot.prev
            call b.destroy()
            set size = size - 1
        endif
        return tag
    endmethod            
    
	// Returns true if there are no elements in the list.
	method isEmpty takes nothing returns boolean
		return top == 0
	endmethod

	// Add element to front (top) of list.
	method addToFront takes integer dataTag returns nothing
		if isEmpty() then
			set top = LinkedListNode.create(dataTag, 0)
			set bot = top
		else
			set top = LinkedListNode.create(dataTag, top)
		endif
        set size = size + 1
	endmethod

	// Add element to back (bot) of list.
	method addToBack takes integer dataTag returns nothing
		if isEmpty() then
			set top = LinkedListNode.create(dataTag, 0)
			set bot = top
		else
			set bot.next = LinkedListNode.create(dataTag, 0)
		endif
        set size = size + 1
	endmethod
endstruct
endlibrary

I'm pretty sure that Ammorth's version leaks Link objects when you destroy your lists. He never iterates through the list and cleans up these references, instead he simply sets the head/tail values to 0 (which, if this were java, would work fine).

I also don't know why he uses an O(n) iteration just to determine the size of the linked list. You can determine this with a simple variable. I'll add it to the above code.

Wow I really don't get what the hell he was trying to do in that Linked List library. The entire API is for each node in the linked-list, rather than the linked-list itself.

On a good note, the system doesn't link. When he deletes a list he deletes the head of the list, which in turn (in the Link API) starts deleting the ones that follow. This means that if you want to destroy a linked-list node that is in a list, you've got to destroy the entire list. There seems to be something funky he does with xparent which is making it harder to read.

This entire library has made me upset. I'm going to take a break. It's funny, but it's true.
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
Its a fairly commen programming data structure, the idea is you have nodes which are "linked" to each other, The advantage is you can add to the list in O(1) time, and since I don't need to look at specific indexes the O(n) search time won't be a problem.
Yeah, I know (otherwise I wouldn't have been able to write what I did).
I think I didn't make myself too clear, what I was looking for were a vjass library with everything made.
This is what I didn't know. I kind of assumed you were mixing up terms when you said "I need a linked list" (it's an odd way of saying you need a library for it).
Berb already created one for you though ^^
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
I'm pretty sure that Ammorth's version leaks Link objects when you destroy your lists. He never iterates through the list and cleans up these references, instead he simply sets the head/tail values to 0 (which, if this were java, would work fine).

Look carefully. In the List destructor he calls the destructor of xfirst which is a Link. Link recursivly calls destroy on its next Link. Done.

I also don't know why he uses an O(n) iteration just to determine the size of the linked list. You can determine this with a simple variable. I'll add it to the above code.

It's just a way to think. One uses a variable one uses recursion or iteration. If you really need that speed, you an always change his script.

Wow I really don't get what the hell he was trying to do in that Linked List library. The entire API is for each node in the linked-list, rather than the linked-list itself.
You can search for a value and then just destroy that link. Kinda nice if you need it.

Just typed this up now, seems to work:

JASS:
library LinkedListLib
struct LinkedListNode
	integer dataTag

	thistype next
	thistype prev
    
	static method create takes integer dataTag, thistype next returns thistype
		local thistype node = allocate()
		set node.dataTag = dataTag
		
		if next != 0 then
			set node.next = next
			set node.prev = next.prev
			
			if node.prev != 0 then
				set node.prev.next = node
			endif
			set node.next.prev = node
		else
			set node.next = 0
			set node.prev = 0
		endif	

		return node
	endmethod
endstruct

struct LinkedList
	LinkedListNode	top
	LinkedListNode	bot
    
    integer size = 0

    // Returns the size of the linked list.
    method getSize takes nothing returns integer
        return size
    endmethod
    
    // Clean linked list elements
    method onDestroy takes nothing returns nothing
        local LinkedListNode n = top
        local LinkedListNode t
        loop
            exitwhen n == 0
            set t = n
            set n = n.next
            call t.destroy()
        endloop
    endmethod
    
    // Returns the extracted 'top' element.
    method extractTop takes nothing returns integer
        local LinkedListNode t = top
        local integer tag = t.dataTag
        set top = top.next
        call t.destroy()
        set size = size - 1
        return tag
    endmethod
    
	// Returns true if there are no elements in the list.
	method isEmpty takes nothing returns boolean
		return top == 0
	endmethod

	// Add element to front (top) of list.
	method addToFront takes integer dataTag returns nothing
		if isEmpty() then
			set top = LinkedListNode.create(dataTag, 0)
			set bot = top
		else
			set top = LinkedListNode.create(dataTag, top)
		endif
        set size = size + 1
	endmethod

	// Add element to back (bot) of list.
	method addToBack takes integer dataTag returns nothing
		if isEmpty() then
			set top = LinkedListNode.create(dataTag, 0)
			set bot = top
		else
			set bot.next = LinkedListNode.create(dataTag, 0)
		endif
        set size = size + 1
	endmethod
endstruct
endlibrary
Seems to work versus a tested library :p
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Look carefully. In the List destructor he calls the destructor of xfirst which is a Link. Link recursivly calls destroy on its next Link. Done.

Yea I realized that after following the node destructor. It's a very confusing way of doing things in any scenario though; a linked-list is an extremely simple data structure but Ammorth's library makes it confusing and unnatural to use.

The user shouldn't be creating/destroying his/her own linked-list nodes. A linked-list should provide the user with an API to use the data-structure that allows him/her to associate data together much like an array would. In an array you simply have to declare an array, you don't have to declare elements of the array and then insert them at the correct location.

It's just a way to think. One uses a variable one uses recursion or iteration. If you really need that speed, you an always change his script.

The Warcraft III engine can handle one more member on a vJass struct I think, so it's not a matter of memory. If it were, I can see why the integer would pose a problem. Since memory isn't an issue, why waste processing resources. Since obtaining O(1) operating time could be achieved with little to no work, I'm surprised that the prestigious community of wc3c.net didn't require that he do this to approve the submission.

You can search for a value and then just destroy that link. Kinda nice if you need it.

But this should be done through the List API, not the Link API. The user shouldn't have to declare his/her node type variables. That should be handled through the List.

Seems to work versus a tested library :p

Well what do you mean, tested library? Are you saying that wc3c.net has more credit than me simply because they approve resources? Rising_Dusk's "intuitive damage detection" still has bugs in it that have been there for the past couple of years. If it were properly tested this would have been discovered, but it wasn't, so how properly do you think the libraries at wc3c.net are actually tested.

With that being said, I'd be glad to correct any errors that you find.

Here's an updated script, for those following:

JASS:
library LinkedListLib
struct LinkedListNode
	integer dataTag     = 0

	thistype next       = 0
	thistype prev       = 0
    
    // Resets the values of all pointers so they don't get confused.
    method onDestroy takes nothing returns nothing
        if next != 0 then
            set next.prev   = prev
        endif
        if prev != 0 then
            set prev.next   = next
        endif
        set dataTag     = 0
        set next        = 0
        set prev        = 0
    endmethod
    
    // Creates a node for the linked-list struct with a data tag and a 'next' pointer.
	static method create takes integer dataTag, thistype next returns thistype
		local thistype node = allocate()
		set node.dataTag = dataTag
		
		if next != 0 then
			set node.next = next
			set node.prev = next.prev
			
			if node.prev != 0 then
				set node.prev.next = node
			endif
			set node.next.prev = node
		endif	

		return node
	endmethod
endstruct

struct LinkedList
	LinkedListNode	top
	LinkedListNode	bot
    
    integer size = 0

    // Returns the size of the linked list.
    method getSize takes nothing returns integer
        return size
    endmethod     
    
	// Returns true if there are no elements in the list.
	method isEmpty takes nothing returns boolean
		return top == 0
	endmethod
    
    // Prints the linked-list to the UI.
    method print takes nothing returns nothing
        local LinkedListNode node = top
        loop
            exitwhen node == 0
            call BJDebugMsg(I2S(node)+".data = "+I2S(node.dataTag))
            set node = node.next
        endloop
    endmethod
    
    // Clean linked list elements
    method onDestroy takes nothing returns nothing
        local LinkedListNode n = top
        local LinkedListNode t
        loop
            exitwhen n == 0
            set t = n
            set n = n.next
            call t.destroy()
        endloop
    endmethod
    
    // Returns the extracted element 'index' steps from the top node.
    method extract takes integer index returns integer
        local integer tag = 0
        local integer i = 0
        local LinkedListNode node = top
        if index < size then
            loop
                exitwhen i == index
                set node = node.next
                set i = i + 1
            endloop
            set tag = node.dataTag
            if node == top then
                set top = top.next
            endif
            if node == bot then
                set bot = bot.next
            endif
            call node.destroy()
            set size = size - 1
        endif
        return tag
    endmethod
    
    // Returns the extracted 'top' element.
    method extractTop takes nothing returns integer
        local LinkedListNode t
        local integer tag = 0
        if not isEmpty() then
            set t = top
            set tag = t.dataTag
            set top = top.next
            call t.destroy()
            set size = size - 1
        endif
        return tag
    endmethod
    
    // Returns the extracted 'bot' element.
    method extractBot takes nothing returns integer
        local LinkedListNode b 
        local integer tag = 0
        if not isEmpty() then
            set b = bot
            set tag = b.dataTag
            set bot = bot.prev
            call b.destroy()
            set size = size - 1
        endif
        return tag
    endmethod       

	// Add element to front (top) of list.
	method addToFront takes integer dataTag returns nothing
		if isEmpty() then
			set top = LinkedListNode.create(dataTag, 0)
			set bot = top
		else
			set top = LinkedListNode.create(dataTag, top)
		endif
        set size = size + 1
	endmethod

	// Add element to back (bot) of list.
	method addToBack takes integer dataTag returns nothing
		if isEmpty() then
			set top = LinkedListNode.create(dataTag, 0)
			set bot = top
		else
			set bot.next = LinkedListNode.create(dataTag, 0)
            set bot = bot.next
		endif
        set size = size + 1
	endmethod
endstruct
endlibrary

Example usage:

JASS:
scope LinkedListTest initializer init
private function init takes nothing returns nothing
    local LinkedList L = LinkedList.create()
    call L.addToFront(5)
    call L.addToFront(8)
    call L.addToFront(11)
    call L.addToFront(19)
    call L.addToFront(21)
    
    call L.extract(3)
    
    call L.addToBack(9)
    
    call L.print()
    call BJDebugMsg("End of printing.")
    
endfunction
endscope

This should print 21, 19, 11, 5, 9, which it does. The printing method was added for debugging, if anybody cares to try and find problems.
 
Last edited:

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Yea I realized that after following the node destructor.
It's a very confusing way of doing things in any scenario though; a
linked-list is an extremely simple data structure but Ammorth's
library makes it confusing and unnatural to use.
For me it wasn't confusing. I think it's a nice library.

Well what do you mean, tested library? Are you saying that
wc3c.net has more credit than me simply because they approve resources?
Rising_Dusk's "intuitive damage detection" still has bugs in it
that have been there for the past couple of years. If it were properly tested
this would have been discovered, but it wasn't, so how properly do you think
the libraries at wc3c.net are actually tested.
You know, "Just typed this up now, seems to work" versus a thread with
4 pages of discussion.

The Warcraft III engine can handle one more member on a vJass struct I think, so it's not a matter of memory. If it were, I can see why the integer would pose a problem. Since memory isn't an issue, why waste processing resources. Since obtaining O(1) operating time could be achieved with little to no work, I'm surprised that the prestigious community of wc3c.net didn't require that he do this to approve the submission.
Never said it was a matter of memory but a matter of style.
Languages like Haskell also don't store an extra paramter but use
(tail-)recursion to loop through the list and get its length [1].
edit: ok, that is a very weak comparison. But you know, other ways of solving a problem are no wrong ways.


The user shouldn't be creating/destroying his/her own linked-list nodes. A linked-list should provide the user with an API to use the data-structure that allows him/her to associate data together much like an array would. In an array you simply have to declare an array, you don't have to declare elements of the array and then insert them at the correct location.

But this should be done through the List API, not the Link API. The user shouldn't have to declare his/her node type variables. That should be handled through the List.
Sometimes you need that control. If you want i can name you some, but i bet you
can get some on your own.
And a List is not like an array. And if you use the API you actually won't use
Links to insert an element into the list.
But if you iterate over your list you need one. But i think it's fine.
To iterate over an array you need an integer. For iterating over lists you need
an iterator or in this case a Link.

But for the two of us this discussion is senseless anyway. I won't change your
opinion you probably won't change mine.
On the other hand everyone can make their own thoughts base on this discussion.
That would make me happy :D Kind of a reward for my long thoughtfull posts ;p

______
[1]: http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/src/GHC-List.html#line-114
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
For me it wasn't confusing. I think it's a nice library.

Well I'm not going to argue with you, it's not that important whether it is confusing or not. I definitely have seen far better implementations of a linked-list than Ammorth's dual library API.

You know, "Just typed this up now, seems to work" versus a thread with
4 pages of discussion.

Clearly you've not familiar with me "typing things up". When I say "it seems to work" it means it does work, and it has been tested to work. I don't post things here that do not work unless I am only trying to express an idea forward.

The "discussion" is also nothing but useless bickering that has nothing to do with the quality of the library that is being submitted. Most of the argument is whether a linked-list library is needed, and then a bunch of preference gags that they always try to impose on submissions.

If the discussion was taken as far as it needed to be, and the necessary steps were taken, then we wouldn't have a size method that has to iterate through the linked-list when it is not necessary and it is in fact slower. By a lot.

Never said it was a matter of memory but a matter of style.
Languages like Haskell also don't store an extra paramter but use
(tail-)recursion to loop through the list and get its length [1].

Style doesn't improve the execution time of code, sensibility does.

But for the two of us this discussion is senseless anyway. I won't change your
opinion you probably won't change mine.
On the other hand everyone can make their own thoughts base on this discussion.
That would make me happy :D Kind of a reward for my long thoughtfull posts ;p

By the time I got to this I had already typed the above, but you're probably right. It really doesn't matter. We should establish some sort of logical conclusion though.

I think that my above implementation of a linked-list is okay. I can see why someone may need the LinkedListNode (that's from my script) but I truly believe that those reasons could be adopted to with a better linked-list API. In my opinion if the user is going to be removing something from a linked-list then it is only sensible that it be extracted (unless the list is being destroyed).

A linked-list, in my opinion, should only be used for the necessity of variable memory requirements along with O(1) insertion and extraction. If you're going to be searching through your linked-list often, then you might want to think about using a tree.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
It's not always about speed but about code-quality. Hence, this is way high-level languages like ruby, perl, python, haskell, you name it exists.

Or to quote the famous:
We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
You see, analyze your code and only optimize the part which is worth optimizing.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Yea I definitely see where it comes from, obviously prematurely optimizing complicated code can become a nightmare but for a linked-list the implementation is always fairly simple. In computer science it seems typical that stacks and linked-lists be coded around the objects which they are necessary in (because of how simple they are).

The optimization required to achieve O(1) time on a size method is minimal, thus there is no harm in "prematurely" optimizing it. In fact, the optimization is more simple than the alternative.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
In fact, the optimization is more simple than the alternative.

It depends. In an OOP-Language this might be true. But using a functional language like Lisp or Haskell using recursion is is way nicer since a list itself is a recursive structure.
Code:
--untested. just wrote it down.
data List = Cons a (List a)
             | Nil

length :: List a -> Int
length x = len_helper 0 xs
  where len_helper i (Cons _ xs) = len_helper (i + 1) xs
        len_helper i Nil         = i
(Some may be interested in this tutorial.)

So coming from a functional language it may be simpler this way.
So your simple really is relative. It may be more efficient but maybe i'm only using list of length 6 through all my map? Than i rather have nice code (which may be a function instead of a member variable) instead of the negligible performance boost. If i ever use longer lists i still can optimize it.

Long story short: the optimization as the alternative may not be the standard way of doing it (or here: the easiest way).
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
We are talking about JASS. Not Lisp, nor Haskell, nor any other language.
I find Berb's library better (in both the efficiency as well as readability).

We're talking about something as simple as a linked list here.
Optimization often comes at the price of a worse readability, but I could easily understand what Berb has written. Anyone with a little programming knowledge would, as it is (again) a basic method.
 
Level 1
Joined
May 28, 2011
Messages
4
I wish I had looked here once more, since I too found the size method extemely ineffecient(However it was a simple thing to change).

Also Berb your list doesn't allow for iteration without changing the list.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Well, it does. I don't like doing it that way, but...

JASS:
local LinkedList L = LinkedList.create()
local LinkedListNode N

// Do stuff to L.
call L.addToFront(8)
call L.addToBack(10)
call L.addToFront(13)
call L.addToBack(9)
call L.addToBack(11)
call L.addToBack(3)

call L.extract(4)
call L.extract(2)

set N = L.top
loop
    exitwhen N == 0
    // Iteration.
    set N = N.next
endloop
 
Level 1
Joined
Jun 4, 2011
Messages
1
At first: Ammorth's List is the most elegant implementation of a linked list I have seen.

It is only local. This nature of it makes it easy to see that there are no bugs. Every implementation from a different style I can think of would be much harder to validate.

The other great thing is encapsulation. It is almost impossible to destroy the internal structure of it.

So lets look at it:

Lep's statements about object oriented style and functional languages is bullshit. There is nothing functional in this linked list. A functional language would have a much simpler idea of a list. They would not even use a list. They would use something like a fast stack and call it list. This has good and bad parts. The only thing is, that it does not make much sense without closure and tail-call-optimization and I don't belive we will have that in jass anytime soon.

So to the size issue. There are two points of view to it: The passive and the aggressive one.

So how often do you need the length operation. The only regular case is when you want to check if a list is empty. Some might argue that you could check weather list.first is zero. I myself think the list should have a method isEmpty. It does not. This is the only point a dislike about it.

On the other hand lets go to your list. (Sorry, you should have kept your mouth closed. I am going to destroy it!) So what if I want to go through the list and want to delete any element that has a special property. So for example a time has passed or the unit attached to it is not alive anymore. In Ammorth's list I get the next Link and destroy the current one. Done! In your list i need to use this extract method. When I use onDestroy it would destroy the structure of your list. It would not be consistent anymore and the size would have the wrong value (I told you in Ammorth's list there is almost no way to get it into a inconsistent state?). So I have to use the extract method. At first it is an O(n) operation (Ammorth's is O(1)), but that is not the worst problem; the method expects the number of the thing in the list. So I have to keep track of what element it is while iterating and calculate the corrections of this number when I insert and remove values while I am iterating over the list (wait, inserting in the middle of the list is not possible, my bad, I thought it was like Ammorth's list where this was no problem) or I have to use the by now nonexisting search method on the list, I have to write by myself before. I have to dive into the implementation of your list like a bucket full of crap. (This method would be O(n) again; by the way all this solve Ammorth's by a simple 20 line O(1) function)

So now a little interlude: Why to use tested software from wc3c and not from some guy post something here: look at the extract method; set bot = bot.next should have been set bot = bot.prev. That would drive everybody crazy. I only saw this because there was a (horrible) time when I wrote at least 2 or 3 linked lists a week.

Next thing: it is late at night; you coded for some hours and you want to get a thing done. Eventually there ends a set iterator.next = iterator in your loop instead of set iterator = iterator.next.

Lets look at that case. In Ammorth's list it would tell you "Aww you can't do that. Bad idea no such operator defined." So you would look at the line for a minute or two, see it, fix it and think you need to get to bed.

On the other hand lets look at your list. The compiler would tell you everything is fine. At runtime you would end in an infine loop that crashes your thread in the best case. If you do more complex side effects in the iteration more crazy stuff could happen. This makes you think you lost your mind and you have so spend a potentially hugh amount of time to figure it out.

Don't tell me that does not happen. Programmers do stupid (really really crazy stupid) mistakes all the time. Noone like to realise that and tries to tell him it is not true, but it is.

That is the great thing of Ammorth's library. It helps you finding your mistakes. It loves the user. Your library only expresses hate for the user of it. This is what is elegance is to me.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
What did you join the site just to say this? It looks like you joined today.

So I have to use the extract method. At first it is an O(n) operation (Ammorth's is O(1)), but that is not the worst problem; the method expects the number of the thing in the list. So I have to keep track of what element it is while iterating and calculate the corrections of this number when I insert and remove values while I am iterating over the list (wait, inserting in the middle of the list is not possible, my bad, I thought it was like Ammorth's list where this was no problem) or I have to use the by now nonexisting search method on the list, I have to write by myself before. I have to dive into the implementation of your list like a bucket full of crap. (This method would be O(n) again; by the way all this solve Ammorth's by a simple 20 line O(1) function)

Yea I typed up this library in like 10 minutes. There is no way I would actually use a linked-list library because the necessities of each linked-list are different. Sometimes you do not need a doubly linked-list, sometimes you do, sometimes you don't need a tail node, etc.. To be honest it sounds like you've used Ammorth's library before, in which case I sense a little bias. No idea why you went through so much elaborate detail to tell me what's wrong with my sandwich. It's just a damn sandwich.

If you were to suggest to me that I add these methods or give the user this type of functionality with it then I could write methods that bend to both our aspirations, but right now you comparing a 5-year-old library from wc3c.net to my 10-minute library from the top of my head I find it pretty complimentary. Especially since you made an account just to say so.
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
you think that your library deserves to be compared against Ammorth's

I'd like to see you quote me on that. If you can't then *. I didn't say I deserved anything. That's just something you pulled to make yourself seem important enough to tell me what I deserve to do and not do. You don't deserve to be a member of this community if you're going to start making the assumption that you know what I think.

If you'll kindly actually read what I typed, I don't even compare my library to Ammorth's library; other than perhaps one instance where his size method was not O(1). Then I said that it was more of a linked-list-node library than a linked-list library, and I said that it was written in a confusing manner.

Now you're telling me I'm being aggressive.

First you're aggressive

I haven't been aggressive at all, until now, when you come here and start telling me what you seem to "know" I'm thinking. Then you start this proprietary about what I deserve to compare to my script.

I've been argued with by 3 different people, one of whom seemed to have created an account for the sole purpose of arguing with me. Now you come here and start telling me what you think I deserve to do and not do. Over the Internet.

I bet this is just a bunch of wc3c.net members who take extreme personal offense to something I have written. That would explain why you're here, HINDYhat, and why somebody just randomly made an account today so they could reply to what I've said.
 
Last edited by a moderator:
Level 28
Joined
Jan 26, 2007
Messages
4,789
The entire debug message-thing is also not very relevant: Berb's library is not a published one.
Had he not written this for one person, but for it to be a generally accepted one, then who knows what he would've added?
I am pretty sure that he would at least have taken the time to first go around asking what could be improved and probably added debug messages to see where something went wrong (if at all).
However, this is not the case. It's a request from one person. Don't start seeing things in it.

Plus it does have a much better readability, which is also a form of elegance in scripts.

We are already way off-topic though.
Someone asked for a linked list library and received two of them, it's his choice which one to use.
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Berb said:
I'd like to see you quote me on that.
Well,
LeP said:
Seems to work versus a tested library :p
Berb said:
Well what do you mean, tested library? Are you saying that wc3c.net has more credit than me simply because they approve resources? Rising_Dusk's "intuitive damage detection" still has bugs in it that have been there for the past couple of years. If it were properly tested this would have been discovered, but it wasn't, so how properly do you think the libraries at wc3c.net are actually tested.
and a general attitude surrounding any mention of Ammoth's library. Maybe you're right and 'aggressive' was too strong a term. In that case, I guess I'm sorry that I can't think of a better one. Regardless, the thread was becoming silly.

Berb said:
That's just some bullshit you pulled out of your ass to make yourself seem important enough to tell me what I deserve to do and not do.
Really, no. I don't care how important or unimportant you might think I am. I was just stating that the thread was becoming silly because of the hostility. And I never told you what I thought you deserved to do. I told you what I thought you thought your library deserved. This in no way reflects what I think about your library. In fact I haven't even reviewed either libraries.

Berb said:
I bet this is just a bunch of wc3c.net members who take extreme personal offense to something I have written. That would explain why you're here, HINDYhat, and why somebody just randomly made an account today so they could reply to what I've said.
Nope, I haven't actively visited wc3c in a very long time, and I haven't written Jass in a very long time. I was just lurking. Maybe you shouldn't make "assumptions" like this.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I told you what I thought you thought your library deserved

Which is completely irrelevant, so why bother. You only skew the topic of this thread even more, which you have already commented on as "silly". So why bother? You clearly have some sort of attachment to what I've said. I'm sorry if I offended you.

But given that you didn't review either libraries, what good is your input? You only create hostility by telling me what I think when you've got nothing but intuitions. The only purpose of your post was to put words in my mouth.

and a general attitude surrounding any mention of Ammoth's library. Maybe you're right and 'aggressive' was too strong a term. In that case, I guess I'm sorry that I can't think of a better one. Regardless, the thread was becoming silly.

There was no attitude towards Ammorth's library, personally I don't mind the guy at all. He's one of the few stand-up fellows you could potentially meet at wc3c.net. You've taken your intuitions on my attitude and somehow translated it so that you can somehow read my thoughts. Please, save that crap for wc3c.net.

God man this starts off as a simple help thread, I type up some library for somebody and then all hell breaks lose. Jesus if you don't have anything pleasant to say then don't say it, LeP, HINDYhat, and HxOrg or whatever, you've contributed nothing to this other than arguments.
 
Level 13
Joined
Mar 16, 2008
Messages
941
God man this starts off as a simple help thread, I type up some library for somebody and then all hell breaks lose. Jesus if you don't have anything pleasant to say then don't say it, LeP, HINDYhat, and HxOrg or whatever, you've contributed nothing to this other than arguments.
What did you expect? You criticize Ammorths library and post a new, in your eyes better one. Did you realy expect to NOT get some criticism? Nobody is perfect, neither Ammorth nor you.
However, both libraries are ok imo. If you realy need a linked list you have to write it for your own purpose and use different methods for tracking and searching depening on what you need.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I've been treated like I've offended the US constitution or something. Jesus. It's Warcraft. Why can't everybody calm down. If somebody disagreed tremendously with something I've said then a PM is the proper course of action, not to spread a disastrous argument across a public forum that is entirely irrelevant to the conversation at hand.

Instead of arguing further I should have PM'd the people involved and explained the situation. I am not innocent in this either. It is completely unnecessary stress for everybody and it's just stupid.
 
If you're using a linked list, what do you want the "count" method for? Linked lists are important in JASS because you can iterate over them. The only use for "count" would be to check if the list is empty, but to test that is obviously o(1) as it just breaks the chain at the head node.

The real reason to dislike Ammoroth's linked list is because it has limited nodes. I have for some reason not released to the public a linked list which is based on the Table library that does provide these things with optimal efficiency. There is also http://www.hiveworkshop.com/forums/jass-functions-413/snippet-static-list-181634/ which is a public JASS resource here and allows you to iterate through a single struct.
 
Status
Not open for further replies.
Top