tag:blogger.com,1999:blog-2546038368249263371.post2798969702015684823..comments2023-03-01T17:58:02.260+01:00Comments on Matej Tymes's Weblog: LinkedArrayQueueMatej Tymeshttp://www.blogger.com/profile/01374039014087672059noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-2546038368249263371.post-18838354645918077022010-05-11T01:36:37.632+02:002010-05-11T01:36:37.632+02:00to maaartin: I have "fixed" the statemen...to maaartin: I have "fixed" the statement regarding the ArrayList object removal. Although the remove first operation only moves all elements to a lower index the speed of such operation is still O(n) which was not acceptable for me. but thank you for your correction and commentMatej Tymeshttps://www.blogger.com/profile/01374039014087672059noreply@blogger.comtag:blogger.com,1999:blog-2546038368249263371.post-32102260730146266772010-05-11T00:22:38.039+02:002010-05-11T00:22:38.039+02:00I think your solution may be optimal, as long as y...I think your solution may be optimal, as long as you need exactly what you described. But there are much more classes in Java, java.util.ArrayDeque could suit your needs, for the operations you need it's fast, although only in amortized time. This means that a single addLast or removeFirst may take a long time, but on the average the time is small and independent of the size. The advantage of ArrayDeque is the fast random access, which you don't need and which is for whatever reason missing in Java, but present in C++ deque.<br /><br />You wrote "[ArrayList's] disadvantage however was that it was not a queue, so the removal of its first element always created a new array into which it copied all elements with the first one excluded.", which is wrong, removal of the first element creates no new array, it "only" moves all the elements.maaartinushttps://www.blogger.com/profile/00411808646708588421noreply@blogger.com