Vault
4.1
|
VCompactingDeque is a template class that subclasses std::deque and adds the ability to "compact" the deque internal structures when the deque drains. More...
#include <vcompactingdeque.h>
Inherits std::deque< T >.
Public Member Functions | |
VCompactingDeque (size_t highWaterMarkRequired=64, size_t lowWaterMarkRequired=0) | |
Constructs the deque with optional specified thresholds. | |
void | pop_front () |
Removes the first element from the queue, possibly triggering a compaction afterward. | |
void | pop_back () |
Removes the last element from the queue, possibly triggering a compaction afterward. | |
void | compact () |
Performs compaction of the deque bookkeeping overhead. | |
Friends | |
class | VMessageUnit |
VCompactingDeque is a template class that subclasses std::deque and adds the ability to "compact" the deque internal structures when the deque drains.
Otherwise, with a standard deque, you can have an apparent memory leak when the queue drains but holds onto lots of internal bookkeeping memory. You can specify in the constructor what thresholds trigger the compaction. Compaction only can happen when you call pop_front() or pop_back() (the methods that may shrink the queue) and do so via a reference or pointer to this subclass. Compaction does not occur on erase() because the returned iterator would be invalid or have to be recalculated.
Definition at line 26 of file vcompactingdeque.h.
VCompactingDeque< _Tp, _Alloc >::VCompactingDeque | ( | size_t | highWaterMarkRequired = 64 , |
size_t | lowWaterMarkRequired = 0 |
||
) | [inline] |
Constructs the deque with optional specified thresholds.
highWaterMarkRequired | compaction occurs only after the queue has grown to this size, and later is drained down to the lowWaterMarkRequired |
lowWaterMarkRequired | compaction occurs only after the highWaterMarkRequired was previously reached, and the queue then drains down to this size |
Definition at line 36 of file vcompactingdeque.h.
void VCompactingDeque< _Tp, _Alloc >::pop_front | ( | ) | [inline] |
Removes the first element from the queue, possibly triggering a compaction afterward.
You will have already called front() to get that element beforehand if you want it. Note that because STL templates do not use virtual methods, this override will not be called should you access this deque via a base class reference or pointer.
Definition at line 50 of file vcompactingdeque.h.
void VCompactingDeque< _Tp, _Alloc >::pop_back | ( | ) | [inline] |
Removes the last element from the queue, possibly triggering a compaction afterward.
You will have already called back() to get that element beforehand if you want it. Note that because STL templates do not use virtual methods, this override will not be called should you access this deque via a base class reference or pointer.
Definition at line 64 of file vcompactingdeque.h.
void VCompactingDeque< _Tp, _Alloc >::compact | ( | ) | [inline] |
Performs compaction of the deque bookkeeping overhead.
You can manually direct a compaction by calling this method. Not necessary if you always use the defined pop_front() and pop_back() functions, because they do this automatically when the high/low water mark thresholds are reached.
Definition at line 78 of file vcompactingdeque.h.