
Dave Harris wrote:
In-Reply-To: <46001891.5080209@gmail.com> igaztanaga@gmail.com (=?ISO-8859-1?Q?Ion_Gazta=F1aga?=) wrote (abridged):
Sink sounds good but now I need a name for operations:
I would be tempted by: clear_and() erase_and()
leaving open what the passed functor was expected to do. Alternatively: clear_and_dispose() erase_and_dispose()
because for me "dispose" is a less committed word than "destroy". It still has the connotation that the container is getting rid of them, but leaves it more open as to what that entails. "Dispose" does have a more specific meaning in garbage collection circles; I don't know if that would be a problem here.
Now I need a new for the function object (disposer? ;-))
I don't know; it's just something which surprised me. Do other people think ilist is closer to list<T> or list<T*>?
For the moment I think people like the current interface.
Well, comparing sizes of STL containers is a bit misleading, because how many bytes are we supposed to use in memory bookeeping if we use standard allocators?
I'd say none. For example, I believe the overhead for a std::slist<T*> node is 2 pointers, half that of ilist<T>.
I suppose you mean std::list (slist is not an standard container). In both cases you need to allocate T. For std::list T's size is A. For ilist T's size is A + 2 pointers. Now you need std::list<T*> with overhead of a node with 3 pointers (T*, a pointer to the next node and a pointer the previous node). This node is allocated dynamically, which typically has a memory allocation header (typical figure 8 bytes in 32 bytes, unless a pool is used). 2 pointers versus 3 pointers + allocation overhead. An intrusive containers will _always_ be more space efficient than a non-intrusive one. I'll try to explain this in the documentation.
-- Dave Harris, Nottingham, UK.
Regards, Ion