Boost logo

Boost Users :

From: Nicola Vitacolonna (vitacolo_at_[hidden])
Date: 2005-09-19 05:53:32


>> Why isn't there any "dequeS" tag in BGL?
>
> Historical accident. If you'd like we could add your implementation
> for deque.

Below you find my implementation for deque.

Regards
Nicola

PS: sorry for forgetting the subject in my previous post, causing a
mess with message threading...

#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <deque>

namespace boost {
     namespace graph_detail {

         struct deque_tag :
         virtual public random_access_container_tag,
         virtual public back_insertion_sequence_tag { };
         // No front_insertion_sequence_tag?

         template <class T, class Alloc>
             deque_tag container_category(const std::deque<T, Alloc>&){
                 return deque_tag();
             }

         template <class T, class Alloc>
             unstable_tag iterator_stability(const std::deque<T,
Alloc>&) {
                 return unstable_tag();
             }

#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
         template <class T, class Alloc>
             struct container_traits< std::deque<T, Alloc> > {
                 typedef deque_tag category;
                 typedef unstable_tag iterator_stability;
             };
#endif
     } // namespace graph_detail

     struct dequeS { };

     template <typename ValueType>
         struct container_gen<dequeS, ValueType> {
             typedef typename std::deque<ValueType> type;
         };
} // namespace boost

// Test
int main(int, char*[]) {
   typedef boost::adjacency_list<boost::vecS,
                                 boost::dequeS,
                                 boost::bidirectionalS> Graph;
   Graph g;
   Graph::vertex_descriptor v1, v2;
   v1 = boost::add_vertex(g);
   v2 = boost::add_vertex(g);
   boost::add_edge(v1, v2, g);
}


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