Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
3.1 KiB

  1. //
  2. // std::set
  3. //
  4. %include <std_container.i>
  5. %include <std_pair.i>
  6. // Set
  7. %define %std_set_methods_common(set...)
  8. set();
  9. set( const set& );
  10. bool empty() const;
  11. size_type size() const;
  12. void clear();
  13. void swap(set& v);
  14. size_type erase(const key_type& x);
  15. size_type count(const key_type& x) const;
  16. #ifdef SWIG_EXPORT_ITERATOR_METHODS
  17. class iterator;
  18. class reverse_iterator;
  19. iterator begin();
  20. iterator end();
  21. reverse_iterator rbegin();
  22. reverse_iterator rend();
  23. void erase(iterator pos);
  24. void erase(iterator first, iterator last);
  25. iterator find(const key_type& x);
  26. iterator lower_bound(const key_type& x);
  27. iterator upper_bound(const key_type& x);
  28. std::pair<iterator,iterator> equal_range(const key_type& x);
  29. #endif
  30. %enddef
  31. %define %std_set_methods(set...)
  32. %std_set_methods_common(set);
  33. #ifdef SWIG_EXPORT_ITERATOR_METHODS
  34. std::pair<iterator,bool> insert(const value_type& __x);
  35. #endif
  36. %enddef
  37. // ------------------------------------------------------------------------
  38. // std::set
  39. //
  40. // const declarations are used to guess the intent of the function being
  41. // exported; therefore, the following rationale is applied:
  42. //
  43. // -- f(std::set<T>), f(const std::set<T>&):
  44. // the parameter being read-only, either a sequence or a
  45. // previously wrapped std::set<T> can be passed.
  46. // -- f(std::set<T>&), f(std::set<T>*):
  47. // the parameter may be modified; therefore, only a wrapped std::set
  48. // can be passed.
  49. // -- std::set<T> f(), const std::set<T>& f():
  50. // the set is returned by copy; therefore, a sequence of T:s
  51. // is returned which is most easily used in other functions
  52. // -- std::set<T>& f(), std::set<T>* f():
  53. // the set is returned by reference; therefore, a wrapped std::set
  54. // is returned
  55. // -- const std::set<T>* f(), f(const std::set<T>*):
  56. // for consistency, they expect and return a plain set pointer.
  57. // ------------------------------------------------------------------------
  58. %{
  59. #include <set>
  60. %}
  61. // exported classes
  62. namespace std {
  63. template <class _Key, class _Compare = std::less<_Key>,
  64. class _Alloc = allocator<_Key> >
  65. class set {
  66. public:
  67. typedef size_t size_type;
  68. typedef ptrdiff_t difference_type;
  69. typedef _Key value_type;
  70. typedef _Key key_type;
  71. typedef value_type* pointer;
  72. typedef const value_type* const_pointer;
  73. typedef value_type& reference;
  74. typedef const value_type& const_reference;
  75. typedef _Alloc allocator_type;
  76. %traits_swigtype(_Key);
  77. %fragment(SWIG_Traits_frag(std::set<_Key, _Compare, _Alloc >), "header",
  78. fragment=SWIG_Traits_frag(_Key),
  79. fragment="StdSetTraits") {
  80. namespace swig {
  81. template <> struct traits<std::set<_Key, _Compare, _Alloc > > {
  82. typedef pointer_category category;
  83. static const char* type_name() {
  84. return "std::set<" #_Key "," #_Compare "," #_Alloc " >";
  85. }
  86. };
  87. }
  88. }
  89. %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::set<_Key, _Compare, _Alloc >);
  90. set( const _Compare& );
  91. #ifdef %swig_set_methods
  92. // Add swig/language extra methods
  93. %swig_set_methods(std::set<_Key, _Compare, _Alloc >);
  94. #endif
  95. %std_set_methods(set);
  96. };
  97. }