I have special data structure requirements that will be used in my Java program. It (Data Structure) should be able to store large amounts of data (not fixed), my main operations are to add at the end, as well as delete / read from the very beginning (LinkedLists look soo so far). But sometimes I also need to be removed from the middle, and this is where LinkedLists are afraid of pain. Can someone suggest me a way around this? Or any optimizations that can make removal less painful with LinkedLists?
Thanks for the help!
LinkedHashMap may suit your purpose. You would use an iterator to pull things from the front and find the entry by key when you need to access the middle of the list
LinkedListfalls for random access. Deleting without random access search is a constant time and therefore very bad for long lists.
LinkedList
ArrayListusually fast. Insertions and deletions from the middle are faster than you might expect, because block memory moves surprisingly fast. Deleting and pasting next to launch will move all of the following data up or down.
ArrayList
ArrayDequesimilar to ArrayList, only it uses a circular buffer and has a weird interface.
ArrayDeque
Regular tip: try it.
evey 10000th, , . : http://experimentgarden.blogspot.com/2009/08/performance-analysis-of-thirty-eight.html
LinkedHashMap - , , . , deque . , , . , "" , , ( ).
: ! , : LinkedMultiSet! LinkedHashMap, . .
, . N, , 1/N, . LinkedList ArrayDeque . ( , , , LinkedList , , ArrayDeque , , - , .)
N
1/N
, , , 1/N, LinkedHashSet, -, , , . LinkedList ArrayDeque , , , , .
LinkedHashSet
, , , , " " (.. , ) , , null. ( , , .) , , , , .
Source: https://habr.com/ru/post/1734740/More articles:How to use jQuery to find the selected index on a DOM object? - jqueryProblems with Curb gem on Mac Snow Leopard - ruby | fooobar.comRequirements for escaping an attribute of an input tag value - htmlpymongo: findandmodify - returns "no such command" - pythonIs there an easy way to automate taking screenshots? - windowsdeveloper tools for os' other than windows - linuxObjective-C: How to call an instance method - objective-cIs it possible to add two language code files, for example, C # and VB.NET in App_Code? If so, how could I achieve this? - c #PHP script to calculate Alpha Krippendorff - phpI want to create a Google App Engine application; have decent JavaSE / Swing + Javascript / (X) HTML + relational database (SQL) - google-app-engineAll Articles