Java: remove a range of indices from a list -


consider linked list of strings got somewhere

linkedlist<string> names = getnames(); 

now, want remove first k elements list. currently, i'll way:

for (int = 0 ; < k ; i++) {     names.removefirst(); } 

is there way more efficiently , instead call like:

names.removerange(0, k); 

note prefer not construct whole new list using sublist(), small k values, popping k times more efficient constructing new list

maybe :

names.sublist(0, k).clear(); 

this more efficient doesn't release memory according sublist it's view:

names.sublist(k, names.size()); 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -