java - Faster Access Version of ArrayList? -


does know of similar arraylist better geared handling large amounts of data possible?

i've got program large arraylist that's getting choked when tries explore or modify arraylist.

presumably when do:

//i int; arraylist.remove(i); 

the code behind scenes runs like:

public t remove(int i){     //let's arraylist stores it's data in t [] array called "contents".     t output = contents[i];     t [] overwrite = new t [contents.length - 1];     //yes, know generic arrays aren't created simply. bear me here...     for(int x=0;x<i;x++){         overwrite[x] = contents[x];     }     for(int x=i+1;x<contents.length;x++){         overwrite[x-1] = contents[x];     }     contents = overwrite;     return output; } 

when size of arraylist couple million units or so, cycles rearranging positions of items in array take lot of time.

i've tried alleviate problem creating own custom arraylist subclass segments it's data storage smaller arraylists. process required arraylist scan it's data specific item generates new search thread each of smaller arraylists within (to take advantage of multiple cpu cores).

but system doesn't work because when thread calling search has item in of arraylists synchronized, can block seperate search threads completing search, in turn locks original thread called search in process, deadlocking whole program up.

i need kind of data storage class oriented containing , manipulating large amounts of objects pc capable.

any ideas?

i need kind of data storage class oriented containing , manipulating large amounts of objects pc capable.

the answer depends lot on sort of data talking , specific operations need. use work "explore" without defining it.

if talking looking record nothing beats hashmapconcurrenthashmap threaded operation. if talking keeping in order, when dealing threads, i'd recommend concurrentskiplistmap has o(logn) lookup, insert, remove, etc..

you may want consider using multiple collections. need careful collections don't out of sync, can challenging threads, might faster depending on various operations making.

when size of arraylist couple million units or so, cycles rearranging positions of items in array take lot of time.

as mentioned concurrentskiplistmap o(logn) rearranging item. i.e. remove , add new position.

the [arraylist.remove(i)] code behind scenes runs like: ...

well not really. can @ code in jdk right? arraylist uses system.arraycopy(...) these sorts of operations. maybe not efficient case isn't o(n).


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -