list_node.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Olaf Krzikalla 2004-2006.
  4. // (C) Copyright Ion Gaztanaga 2006-2013
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // See http://www.boost.org/libs/intrusive for documentation.
  11. //
  12. /////////////////////////////////////////////////////////////////////////////
  13. #ifndef BOOST_INTRUSIVE_LIST_NODE_HPP
  14. #define BOOST_INTRUSIVE_LIST_NODE_HPP
  15. #ifndef BOOST_CONFIG_HPP
  16. # include <boost/config.hpp>
  17. #endif
  18. #if defined(BOOST_HAS_PRAGMA_ONCE)
  19. # pragma once
  20. #endif
  21. #include <boost/intrusive/detail/workaround.hpp>
  22. #include <boost/intrusive/pointer_rebind.hpp>
  23. namespace boost {
  24. namespace intrusive {
  25. // list_node_traits can be used with circular_list_algorithms and supplies
  26. // a list_node holding the pointers needed for a double-linked list
  27. // it is used by list_derived_node and list_member_node
  28. template<class VoidPointer>
  29. struct list_node
  30. {
  31. typedef typename pointer_rebind<VoidPointer, list_node>::type node_ptr;
  32. node_ptr next_;
  33. node_ptr prev_;
  34. };
  35. template<class VoidPointer>
  36. struct list_node_traits
  37. {
  38. typedef list_node<VoidPointer> node;
  39. typedef typename node::node_ptr node_ptr;
  40. typedef typename pointer_rebind<VoidPointer, const node>::type const_node_ptr;
  41. BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_previous(const const_node_ptr & n)
  42. { return n->prev_; }
  43. BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_previous(const node_ptr & n)
  44. { return n->prev_; }
  45. BOOST_INTRUSIVE_FORCEINLINE static void set_previous(node_ptr n, node_ptr prev)
  46. { n->prev_ = prev; }
  47. BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(const const_node_ptr & n)
  48. { return n->next_; }
  49. BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(const node_ptr & n)
  50. { return n->next_; }
  51. BOOST_INTRUSIVE_FORCEINLINE static void set_next(node_ptr n, node_ptr next)
  52. { n->next_ = next; }
  53. };
  54. } //namespace intrusive
  55. } //namespace boost
  56. #endif //BOOST_INTRUSIVE_LIST_NODE_HPP