
For completeness: { std::list<int, boost::monotonic::allocator<int> > list(storage); generate_n(back_inserter(list), 100, rand); cout << "list: " << storage.used() << endl; } list: 1612 deque: 736 vector: 1724 default rope: 608 rope<100>: 464 On Mon, Jun 15, 2009 at 11:30 AM, Christian Schladetsch < christian.schladetsch@gmail.com> wrote:
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.