quote:Original post by Anonymous Poster
well just whereever he says "node" read it as "iterator", I mean really.
Really what?
Nodes are things used to build certain containers.
Iterators are things to move through certain containers.
Replacing "node" with "iterator" will change what he wrote completely, and it would change it to something other than what he intended.
They have different properties -- nodes store things and have two pointers, iterators don''t store anything, have unknown internal construction, and a few members to provide pointer-like semantics. One cannot simply replace "node" with "iterator" in what he wrote.
An iterator can''t be used to steal nodes, because the iterator shouldn''t provide access to the node (i.e. won''t let you unlink it from one chain and link it onto another).
quote:So he''s just removing one object from a list and inserting it into another. It is just that he is doing it more efficiently.
The point is, his list absolutely should not expose nodes, ever.
quote:I don''t know the STL list that well (I prefer vectors, maps, and the other containers)
It isn''t a question of which you prefer, it''s a question of which is correct.
quote:but doesn''t it have a splice function or something?
Yes.
And it quite probably will be implemented by unlinking nodes from one list and putting them in the other -- which will provide the same ultimate result as the StealNode function but without exposing Nodes.
quote: If it took a range of iterators and you throw a remove algo in, you''d probably be able to get what he is doing.
Probably.
quote:As to the allocators, don''t allocators do the equivilent of overloading new? Since nodes store the object in the node itself allocators have no relevance and thus cannot be used in an implementation, unless the implementation doesn''t store the object in the node, but wouldn''t that be less efficient?
It''d be a pointer dereference and a memory allocation less efficient; I don''t think it''s forbidden, though; the standard generally specifies only the properties of the interface, not the implementation.