giftrice.blogg.se

Java queue to array
Java queue to array







Java queue to array code#

Also, just like you mentioned, we have to keep our implementation private, such that the client doesnt have to know how the data structure is implemented, and design the code keeping in mind that it will be a part of a bigger application, as stacks and queues are fundamental datastructures. so it probably will be tested for speed, with im assuming some pretty large queue size. really needed that clarification :D the only reason i made this post was to clear up the confusion i was having after reading a few of those posts over the web where they were making those claims.īut yes, this is an algorithm assignment, and the course involves in making algorithms to increase performance of codes in real world applications. I also wanted to go with linked list, as its easy to code, and doesnt involve all the low level issues that you mentioned.

java queue to array

That way, if it became necessary, I could try different implementations without having to change or break anything else. and arrays are the way to go" - that sounds like total rubbish to me - anyone else want to offer an opinion?įinal observation: in real life, if this was a critical part of some performance sensitive big application, I would write a small class to encapsulate this functionality, and keep the implementation (array / linked list / tree set etc) private. IMHO linked lists are better to work with in every respect, except for the speed of accesing random elements by their index number (but see first sentence above).Īs for " linkedlists being old, unfashioned n stuff.

java queue to array

Do you reeally care if they take 1 microSecond vs 2 microSeconds?Įasy to code, easy to read and understand, easy to debug, easy to modify or enhance - those are the issues that matter (listed in increasing order of importance).Īrrays seem simple, but you have to deal with low-level issues like growing the array when its initial capacity is exceeded, of shuffling down all gthe following elements when you delete one in the middle. Unless you are processing a vast number of dequeues against a huge queue then "faster" is not going to be relevant.







Java queue to array