Boost logo

Boost Users :

From: Filip Konvička (filip.konvicka_at_[hidden])
Date: 2007-05-31 11:01:46


>> Out of 3 items, I can see the leaf nodes (left_ and right_) correctly,
>> but the head node is displayed incorrectly. When I add some more items,
>> I still see just 2 or 3 items and the rest is garbage. Perhaps there is
>> something about _compressed_base which needs special treatment?
>>
>
> Yes, this is related to a special memory-saving technique described at:
>
> http://boost.org/libs/multi_index/doc/tutorial/indices.html#ordered_node_compression
>
> I cannot check, but I think the correct expression for head should be:
>
> *((ordered_index_node_impl*)(
> ((ordered_index_node_impl*)(ordered_index_node_trampoline<$T1>*)($c.member)
> )->parentcolor_&~1u))
>
> Does this work? If so, we can move on to the rest of node types :)
>
Yes!! Wow, that was way simpler than I expected. The resulting
visualizer works perfectly with the support code that I posted earlier:

boost::multi_index::detail::header_holder<boost::multi_index::detail::ordered_index_node<*>,*>{
  preview(#("multi_index_container data"))
  children(
    #(
      #tree(
            head :
*(boost::multi_index::detail::ordered_index_node_compressed_base*)(boost::multi_index::detail::ordered_index_node_impl*)(void*)(((boost::multi_index::detail::ordered_index_node_trampoline<$T1>*)($c.member))->parentcolor_&~1U),
            size : ((multi_index_helper_3<$T2>*)&$c)->node_count,
            left : left_,
            right : right_,
            skip : 0
      ) :
*(multi_index_helper<boost::multi_index::detail::ordered_index_node<$T1>
>*)(boost::multi_index::detail::ordered_index_node<$T1>*)(boost::multi_index::detail::ordered_index_node_trampoline<$T1>*)(&$e)
    )
  )
}

(The visualizer needs all the boost::multi_index::detail:: specification
stuff...)

I tried hashed_unique right away, and I have another issue:

boost::multi_index::detail::header_holder<boost::multi_index::detail::hashed_index_node<*>,*>{
  preview(#("multi_index_container hashed data"))
  children(
    #(
      orig : [$c,!],
      #list(
            head :
*((hashed_index_node_impl*)(hashed_index_node_trampoline<$T1>*)($c.member)),
            size :
((multi_index_helper_3<$T2>*)((header_holder<hashed_index_node<$T1>,$T2>*)(((char*)&$c)+4)))->node_count,
            next : next_
      ) : *(multi_index_helper<hashed_index_node<$T1>
>*)(hashed_index_node<$T1>*)(hashed_index_node_trampoline<$T1>*)(&$e)
    )
  )
}

It seems that accessing node_count using the same technique as with
ordered_unique does not work - I'm off by 4 bytes (see the
(((char*)&$c)+4) expression). Clicking through the head node's next_
members reveals that I'm cycling between just 2 nodes (there should be 5
of them), and the data is garbage. So perhaps I'm missing some
additional cast somewhere, but I don't see where.

There is one more issue with hashed indices: the type names tend to get
so long, that when I use more than one index with hashed_unique, the
name gets cut in the half (some fixed string length...) and fails to
match the pattern (there're loads of boost::mpl::na or something like
this). If there's no compiler flag to set, this will probably be a
limitation.

Cheers,
Filip


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