list.qbk 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. [section boost_python_list.hpp]
  2. [section Introduction]
  3. Exposes a [link concepts.objectwrapper.typewrapper_concept_requirements TypeWrapper] for the Python [@http://www.python.org/doc/current/lib/typesseq-mutable.html list] type.
  4. [endsect]
  5. [section Class `list`]
  6. Exposes the [@http://www.python.org/doc/current/lib/typesseq-mutable.html mapping protocol] of Python's built-in `list` type. The semantics of the constructors and member functions defined below can be fully understood by reading the [link concepts.objectwrapper.typewrapper_concept_requirements TypeWrapper] concept definition. Since `list` is publicly derived from [link object_wrappers.boost_python_object_hpp.class_object `object`], the public `object` interface applies to `list` instances as well.``
  7. namespace boost { namespace python
  8. {
  9. class list : public object
  10. {
  11. public:
  12. list(); // new list
  13. template <class T>
  14. explicit list(T const& sequence);
  15. template <class T>
  16. void append(T const& x);
  17. template <class T>
  18. long count(T const& value) const;
  19. template <class T>
  20. void extend(T const& x);
  21. template <class T>
  22. long index(T const& x) const;
  23. template <class T>
  24. void insert(object const& index, T const& x); // insert object before index
  25. object pop(); // remove and return item at index (default last)
  26. object pop(long index);
  27. object pop(object const& index);
  28. template <class T>
  29. void remove(T const& value);
  30. void reverse(); // reverse *IN PLACE*
  31. void sort(); // sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1
  32. template <class T>
  33. void sort(T const& value);
  34. };
  35. }}
  36. ``
  37. [endsect]
  38. [section Example]
  39. ``
  40. using namespace boost::python;
  41. // Return the number of zeroes in the list
  42. long zeroes(list l)
  43. {
  44. return l.count(0);
  45. }
  46. ``
  47. [endsect]
  48. [endsect]