list_set_view.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Boost.Bimap
  2. //
  3. // Copyright (c) 2006-2007 Matias Capeletto
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. /// \file views/list_set_view.hpp
  9. /// \brief View of a side of a bimap that is signature compatible with std::list.
  10. #ifndef BOOST_BIMAP_VIEWS_LIST_SET_VIEW_HPP
  11. #define BOOST_BIMAP_VIEWS_LIST_SET_VIEW_HPP
  12. #if defined(_MSC_VER)
  13. #pragma once
  14. #endif
  15. #include <boost/config.hpp>
  16. #include <boost/bimap/container_adaptor/list_adaptor.hpp>
  17. #include <boost/bimap/detail/set_view_base.hpp>
  18. #include <boost/bimap/detail/map_view_base.hpp>
  19. namespace boost {
  20. namespace bimaps {
  21. namespace views {
  22. /// \brief View of a bimap that is signature compatible with std::list.
  23. /**
  24. This class uses container_adaptor and iterator_adaptor to wrapped a index of the
  25. multi_index bimap core so it can be used as a std::list.
  26. See also const_list_set_view.
  27. **/
  28. template< class CoreIndex >
  29. class list_set_view
  30. :
  31. public BOOST_BIMAP_SEQUENCED_SET_VIEW_CONTAINER_ADAPTOR(
  32. list_adaptor,
  33. CoreIndex,
  34. reverse_iterator, const_reverse_iterator
  35. ),
  36. public ::boost::bimaps::detail::
  37. set_view_base< list_set_view< CoreIndex >, CoreIndex >
  38. {
  39. BOOST_BIMAP_SET_VIEW_BASE_FRIEND(list_set_view,CoreIndex)
  40. typedef BOOST_BIMAP_SEQUENCED_SET_VIEW_CONTAINER_ADAPTOR(
  41. list_adaptor,
  42. CoreIndex,
  43. reverse_iterator, const_reverse_iterator
  44. ) base_;
  45. public:
  46. list_set_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) :
  47. base_(c) {}
  48. list_set_view & operator=(const list_set_view & v)
  49. {
  50. this->base() = v.base();
  51. return *this;
  52. }
  53. BOOST_BIMAP_VIEW_ASSIGN_IMPLEMENTATION(base_)
  54. BOOST_BIMAP_VIEW_FRONT_BACK_IMPLEMENTATION(base_)
  55. // Rearrange Operations
  56. void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
  57. BOOST_DEDUCED_TYPENAME base_::iterator i)
  58. {
  59. this->base().relocate(
  60. this->template functor<
  61. BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
  62. this->template functor<
  63. BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(i)
  64. );
  65. }
  66. void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
  67. BOOST_DEDUCED_TYPENAME base_::iterator first,
  68. BOOST_DEDUCED_TYPENAME base_::iterator last)
  69. {
  70. this->base().relocate(
  71. this->template functor<
  72. BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
  73. this->template functor<
  74. BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(first),
  75. this->template functor<
  76. BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(last)
  77. );
  78. }
  79. };
  80. } // namespace views
  81. } // namespace bimaps
  82. } // namespace boost
  83. #endif // BOOST_BIMAP_VIEWS_LIST_SET_VIEW_HPP