Snippet Linked List

Trollvottel

never aging title
Reaction score
262
I actually plan to add an extension which allows the user to use a Sorted List which stores Structs which extend from the type Comparable. I think this could be useful in some cases. What do think about it?
 

Nestharus

o-o
Reaction score
84
I honestly think that the linked list should only deal with integers and let people use the integers retrieved from the list to access their own arrays or structs or w/e =p.

As for the actual code, it could be optimized a lot. I could give you a linked list that uses 0 structs and extraneous calls : P. It's about as optimized as it can be =).

I made it inside of Timed a long time ago, it was one of the many optimization thingies I put in there : |.

It pretty much does all the stuff yours does, but without the extra calls. It's as light and as bare as can be =P. Also, the code is very ugly because of how light it is ^_^. It's almost pure JASS : P.

Oh yea, and my stuff doesn't have any dummy slots... so it saves indexes... : P. All it has are the slots that are being used =). I might even submit it, it's very good code o-o.

I'll post here first and then we can decide =). The interface for it is a little ugly as it always requires the list =P.

like- List.add(list), lol.
 

Trollvottel

never aging title
Reaction score
262
I honestly think that the linked list should only deal with integers and let people use the integers retrieved from the list to access their own arrays or structs or w/e =p.

As for the actual code, it could be optimized a lot. I could give you a linked list that uses 0 structs and extraneous calls : P. It's about as optimized as it can be =).

I made it inside of Timed a long time ago, it was one of the many optimization thingies I put in there : |.

It pretty much does all the stuff yours does, but without the extra calls. It's as light and as bare as can be =P. Also, the code is very ugly because of how light it is ^_^. It's almost pure JASS : P.

Oh yea, and my stuff doesn't have any dummy slots... so it saves indexes... : P. All it has are the slots that are being used =). I might even submit it, it's very good code o-o.
what do you want to say me with this? i dont get anything.
actually this list is optimized enough imo, there are no big coding flaws in it, it does not use slow functions and it does not use loops either.

I'll post here first and then we can decide =). The interface for it is a little ugly as it always requires the list =P.

like- List.add(list), lol.

how should you call methods on structs without requiring the struct itself? o0
 

Trollvottel

never aging title
Reaction score
262
Well, speed gain ~ 0.
Better have a nice looking code with a nice interface than having an ugly looking code with ugly interface.

also:

[ljass]integer list[/ljass]

:/
 

Nestharus

o-o
Reaction score
84
Ok.
Well, speed gain ~ 0.

Time to prove you wrong ><

Hashtables are quite literally half the speed of arrays, making linked lists kinda pointless o-o

Also, I benchmarked the list utilities =p.

The one I posted:

add is 2.25x faster
next when with dynamic adding (no next) is 1.25x faster

When doing a value + add or next, it only goes up by 1 or 2 ms, so it's still about 2.25x and 1.25x faster (hardly changes o-o)

And Table, by Vexorian, which is literally just a hashtable, pwns both of them.

Like I keep saying, Linked lists or pretty much useless now o-o. Hashtables rape them : o.

When it comes to actual Linked Lists, I think the code I got there is about as fast as you are going to get, but yea, 100% obsolete =).
 

Trollvottel

never aging title
Reaction score
262
Hashtables and Linked List are for completely different things!

Also, this is not all about speed, i dont see where speed matters when using a linked list (yeah, it should not be too slow, thats right :rolleyes:)

Again

Better have a nice looking code with a nice interface than having an ugly looking code with ugly interface.
Even if its a tiny bit smaller. this is not an attachement system or sth that needs to save every microoperation...
 

Nestharus

o-o
Reaction score
84
Well, I guess you are right. The beauty about a linked list is that the data never gets split up ^_^. Even if you remove an element from the very middle, you can still loop through it without getting any bad values =P. It relinks it as you remove it : D.

Imma submit my code then...

add is 2.25x faster
next when with dynamic adding (no next) is 1.25x faster

><
 

Azlier

Old World Ghost
Reaction score
461
>Hashtables are quite literally half the speed of arrays, making linked lists kinda pointless o-o

A doubly linked list consists of two or more array calls with most methods. A singly linked list requires just one or two. Logically, you need two or more hashtable calls for most methods for a doubly linked list made with hashtables. I do believe that the array version just won.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Like I keep saying, Linked lists or pretty much useless now o-o. Hashtables rape them : o.
You keep saying that, and I'll practise ignoring you.

T32 is essentially a linked list. I'd LOVE to see you optimise that using hashtables.

Go on, Nestharus. Prove your point. Increase the loop speed of T32 by replacing linked lists with a hashtable. :)
 

Trollvottel

never aging title
Reaction score
262
Small update:

-Added the attribute size which is the amount of nodes in the list (readonly)
-Added the method flush which empties the list instantly
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top