Share

Tree Container Library

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

Exposing partial order of Tree

You are viewing a single message from this topic. View all messages.

  1. 2006-04-18 09:53:48 UTC
    I appreciate your TCL. It is very useful in real world applications. It should be pointed out that, a tree (except seq_tree) implies an partial order just like your design of node_compare_type policy. But, currently, this partial order is hidden in the internal of tree rather than exposed in public interface. For explicitly, here may be 2 patterns available: (Take unique_tree as example)
    1. std::map-like interface:
    unique_tree<>::insert(key_type parentid, key_type id, stored_type obj), Here stored_type is mapped_type.
    original: unique_tree<>::insert(stored_type parent, stored_type obj).

    2. functor-based interface:
    unique_tree <key_type, stored_type, GetKeyFunctor>::insert(key_type parentid, stored_type obj)
    {
    // Call pattern #1
    unique_tree<>::insert(parentid, GetKeyFunctor(obj), obj);
    }

    key_type GetKeyFunctor(stored_type obj)
    {
    return obj.GetKey();
    }

    Summary: Original tree interface binds key_type and store_type too tightly, because key_type is enough. When searching in the tree or pointing out the parent node, possibly, we do not have the entire store_type but only a key_type. Decoupling the key_type and stored_type may improve TCL usage.
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.