Boost logo

Boost Users :

Subject: [Boost-users] [Intrusive] List Manipulation and Management
From: Freddie Witherden (freddie_at_[hidden])
Date: 2009-09-26 14:18:58


Hi all,

I am moderningising/porting some old Pascal code. The code makes
extensive use of an intrusive singly-linked structure termed a node.

In order to replicate this idiom in C++ I have been investigating the
Intrusive library. However, I have several questions about list
manipulation and memory management. Firstly, in the code being ported
all nodes can be thought of as being heap allocated. The following is
extremely common (pseudo-code):

Node* afunction(...);
[...]
Node* tail;
link(tail, afunction(...));

This is rather nice as in O(1) you can append a returned list to your
current list. However, I am unsure how I would accomplish this in
Boost Intrusive. I can not seem to find a way to create the somewhat
fragile intrusive::list from just a node (be it singly or doubly
linked). The list class also seems to take T& as opposed to T* when
pusing to the front/back of the list. My experience of intrusive
structure in C was that you'd always take a pointer when adding a new
link.

Secondly, when dealing with heap allocated items, which need to be
deleted, the current code uses a while loop to call each nodes
destructor. What is the intrusive equivalent?

Of course, I am open to ideas/suggestions about better ways to
accomplish the above tasks :)

Regards, Freddie.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net