|
Boost : |
Subject: Re: [boost] Proposal: Monotonic Containers
From: Christian Schladetsch (christian.schladetsch_at_[hidden])
Date: 2009-06-14 19:30:04
>
>>>
>>> The main benefit of a rope over a vector is that a rope can grow
>>> indefinately without ever needing to be resized.
>>>
>>>
>>>
>>
>> How does this differ from a deque?
>>
>>
>
> deque has fixed size blocks
monotonic::inline_storage<4000> storage; // create local storage on
the stack
{
{
std::deque<int, boost::monotonic::allocator<int> >
deque(storage);
generate_n(back_inserter(deque), 100, rand);
cout << "deque: " << storage.used() << endl;
}
storage.reset();
{
std::vector<int, boost::monotonic::allocator<int> >
vector(storage);
generate_n(back_inserter(vector), 100, rand);
cout << "vector: " << storage.used() << endl;
}
storage.reset();
{
monotonic::rope<int> rope(storage);
generate_n(back_inserter(rope), 100, rand);
cout << "default rope: " << storage.used() << endl;
}
storage.reset();
{
monotonic::rope<int, 100> rope2(storage);
generate_n(back_inserter(rope2), 100, rand);
cout << "rope<100>: " << storage.used() << endl;
}
storage.reset();
}
>>>
deque: 736
vector: 1724
default rope: 608
rope<100>: 464
Deque is certainly a valid container to use with monotonic allocators which
avoids resizing. The main benefit of a rope over a deque is that it can span
the stack/heap boundary.
Obviously, I have to do some performance testing of deque vs. `rope`.
Christian.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk