Snippet Double-Ended Queue

Romek

Super Moderator
Reaction score
963
The C++ Example in the wiki uses both push and pop.

Edit:

1.1
  • Renamed .peek() to .front()
  • Added .back()
 

Nestharus

o-o
Reaction score
84
vJASS uses a C# interface and JASS uses a VB interface.

You're using a C++ interface, and so everyone's getting confused when they're reading your methods.
 

Romek

Super Moderator
Reaction score
963
> vJASS uses a C# interface
No. o_O

> JASS uses a VB interface.
No. o_O

> You're using a C++ interface
No. o_O
I'm using the method names which I liked the most, which happen to be used in C++. You're getting confused because you either don't know what the difference between a queue and stack is, or you simply got muddled up. I'm betting for the former, and you're trying to make excuses. :p

> The ones I used always had Enqueue and Dequeue. (CSharp/VB.NET)
Hmm, oh well. I prefer push and pop; sorry (you can always change 'em if you want). :p
 

Jesus4Lyf

Good Idea™
Reaction score
397
Let's hear some advantages over this, or let's GY and move on?
push ~ addToEnd
pop ~ detachFirst
peek ~ getFirst

And it is all structy and nice with debug messages and such and extra flexibility.

Pretty rare that you'd actually need a queue of integers, not structs? Doesn't seem too useful?
 

Romek

Super Moderator
Reaction score
963
> Let's hear some advantages over this, or let's GY and move on?
That's like comparing a jump parabola and a jump system. :p

This is far simpler than a linked list, though it works in a similar way. It's also easier to use as a result. I wasn't particularly aware of any Linked Lists on this site.. So yeah, It's true that this is quite limited in comparison.

> And it is all structy and nice with debug messages and such and extra flexibility.
Debug messages aren't a problem; I can add those in 4 seconds.
I personally don't like things like these being modules. More flexibilty if it's limited to a struct? Quite the opposite, actually.

> Pretty rare that you'd actually need a queue of integers, not structs?
I know that you know that they're the same things.
 

quraji

zap
Reaction score
144
>And it is all structy and nice with debug messages and such and extra flexibility.

I thought you didn't like structs :eek:

>Pretty rare that you'd actually need a queue of integers, not structs? Doesn't seem too useful?

lol.
 

Vestras

Retired
Reaction score
248
> vJASS uses a C# interface

Dude, do you even know what C# and VB.NET is? :nuts:
vJass has like no resemblances to C# whatsoever. Hell, you don't even declare members the same way.

I guess we all have different names for the same thing. If it's so bad for us, we can change the names in less than half a minute anyways.

> getting confused when they're reading your methods.

I'm not getting confused :confused:
 

Jesus4Lyf

Good Idea™
Reaction score
397
>I thought you didn't like structs :eek:
I don't like struct interfaces to systems that don't require a struct interface (ie. are simpler without it).

This, obviously, needs structs. So I'd prefer a system which doesn't require a typecast from integer to one that does.

>I personally don't like things like these being modules. More flexibilty if it's limited to a struct? Quite the opposite, actually.

Flexibility isn't everything. Simple interfaces are worth more, generally (no struct typecast).

>That's like comparing a jump parabola and a jump system.
Can't say I agree.

So really though... is this redundant or not? The linked list module is clearly going to be easier to use because you don't need to attach or typecast, and even if it wasn't, it is approved and covers the same functionality...
We don't want two, do we?
 

Nestharus

o-o
Reaction score
84
I know C# yes

I also know basic VB syntax =).

I just compare it to C# with the objects =P. In C#, everything is in objects, oh well ^_^.

There are no queue utilities, so I guess this would be an ok utility in my opinion : ).
 

Romek

Super Moderator
Reaction score
963
> So I'd prefer a system which doesn't require a typecast from integer to one that does.
Why? :p

> Flexibility isn't everything. Simple interfaces are worth more, generally (no struct typecast).
You said that a module was more flexible, I was stating that it isn't :p. I don't see what you've got against integer -> struct typecasting. There's absolutely nothing wrong with it.

Anyway, me thinks I'll update this to a Double-Ended queue soon.
Then it'd be much more usable, and still have a simpler interface than linked list.
If this is graveyarded by then, I'll repost it. Otherwise, I'll simply update + bump this.

> And what does queuing integer do, and how is it useful to us...? o_O
It's relatively difficult to find a specific use of this compared to just about any other snippet/system. =|
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
So... That means you only know the use for it, if you need it?

That's only slightly confusing... :nuts:
 

Jesus4Lyf

Good Idea™
Reaction score
397
>I don't see what you've got against integer -> struct typecasting. There's absolutely nothing wrong with it.
Just interface convenience. For array member structs you'd need to even attach, making this less efficient, am I wrong?

>and still have a simpler interface than linked list.
It doesn't as is, let alone when you add the rest of the features.

>It's relatively difficult to find a specific use of this compared to just about any other snippet/system. =|
Considering you used to hound me for a demo map and example for every thing I submitted, I think you ought do the same! :thup:
 

Romek

Super Moderator
Reaction score
963
> For array member structs you'd need to even attach, making this less efficient, am I wrong?
What do you mean? Structs with array members will work without problems.

> It doesn't as is, let alone when you add the rest of the features.
It does as is, and will do.
Linked lists allow the user to manipulate the nodes (and many of the linkedlist functions would return the node instead of the value). This and a double-ended queue won't.

> Considering you used to hound me for a demo map and example for every thing I submitted, I think you ought do the same!
Only when a demo map was actually needed. I can't demonstrate anything whatsoever with a demo map here. :p

Edit:

Version 2.0
This is now a double-ended queue. It has a heck load more functionality, as well as numerous new methods. Overall, this is basically a linked list without public access to nodes (which can be unnecessary in most/many scenarios) :p.
I've added numerous alternate method names.
Also has debug message. Hooray.​


There may be a bug or two, I haven't fully tested all the methods, and am in a bit of a hurry.
 

Jesus4Lyf

Good Idea™
Reaction score
397
JASS:
//  ||  information:                                     ||
//  ||   <a href="http://en.wikipedia.org/wiki/Double-ended_queue" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://en.wikipedia.org/wiki/Double-ended_queue</a> ||

NO! DOCUMENTATION! SPEAK TO ME ARE YOU OK? What did they do to you! You have URL tags sticking out of you! =[

"This has been done before, my friend"
Is what I said to you.
But Romek, you still went and wrote,
A double ended queue.

"It's good to have a list of ints"
Is what you did deduce.
But Romek, please come help me find,
A realistic use?

And once again, I must compare,
Your stitching up of nodules,
To what we already approved -
A standard linked list module...
 

Romek

Super Moderator
Reaction score
963
> NO! DOCUMENTATION! SPEAK TO ME ARE YOU OK? What did they do to you! You have URL tags sticking out of you! =[
Would've been too long, it's only a snippet afterall.
Sticking out URL tags aren't my fault. It seems that even when I remove them, and uncheck "automatically parse links..", they still return after a while. =|

I already said that this is much simpler to use than a linked list. You don't manipulate the nodes at all.
Also, I dislike the use of modules like that, it's less flexible for sure, and limits the use of the linked list to one struct type, and to within the struct only.
 
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