I have about 10 billion records (x86-64). Size of every record is 16 bytes.
Every hour I have to add about 1 million new records and remove about 1 million old records. For calculations I need fast linear addressing of records, i.e. buf[i] must be fast. Subj.
1. vector<my_record>.
The best, I think. It has fast linear addressing. New elements are added fast when I use reserve(). But cropping container from the begin means move about 160 Gb in memory. This take much time cause I use swap. I'm not happy owner of computer with 1 Tb RAM. This is the only lack.
2. deque<my_record>.
Is there way to reserve() additional memory and mass pop_fronts() without many memory freeing and reallocations?
3. list<my_record>, map<my_record>.
It has slow linear addressing (find buf[i]).
2. deque<my_record>.
Is there way to reserve() additional memory and mass pop_fronts() without many memory freeing and reallocations?
deque does not do reallocations (aside from rare control structure reallocations).
Every hour I have to add about 1 million new records and remove about 1 million old records.
Do you add and remove it in chunks (whole million is added at the same time, when the time comes exactly that million will be removed), you might want to roll-out your own deque-like structure based on list of vectors. That vay you can have fast insertion and removal of elements without sacrificing much or random access speed.