You can't use an STL container (e.g. set
, which doesn't technically even need to me a BST as far as I know), as it doesn't provide you with access to the underlying structure.
Your options are:
As you already mentioned, writing your own BST.
Simply using a secondary BST (or heap) which is ordered by your integer value.
Using Boost's
multi_index_container
.