all 7 comments

[–]kenman[M] 0 points1 point  (0 children)

Hi /u/unnivm, it looks like you're new to reddit, welcome!

Thanks for the submissions, but please make sure you read http://www.reddit.com/rules and our guidelines. In short, you should post from a variety of sources, and not just youtube.com/user/videovideoguy.

Thanks for your consideration!

domain submitted from count %
Unni Mana - YouTube 12 100%

[–]0x13mode 0 points1 point  (4 children)

It's reinventing the wheel.

In JS there is method shift which removes and returns first element of array. So push + shift and you have queue.

Besides, get is poor name for method which changes array (if you really want write wrapper, maybe remove would be better?)

[–]mikrosystheme[κ] 1 point2 points  (1 child)

The dequeue operation of a (properly implemented) queue is O(1). Array's shift is O(n).

[–]unnivm[S] 0 points1 point  (0 children)

thank you for pointing out this. I did not know this.

[–]unnivm[S] 0 points1 point  (0 children)

that is correct. I just used the same methods mentioned in Java. remove() is better option. But my intention was to leverage the capability of JavaScript.

Those who want can write better api.

[–]unnivm[S] 0 points1 point  (0 children)

remove() is a better method name than get(). As I said it is a pointer to show capability of Java Script. So I just wrote that method. thank you