py::builtins::list::extend¶
template <class iterable_type>
void extend(const iterable_type& iterable);
Appends all element of given iterable to the list.
Tip
Same as:
this->insert(-1, iterable.begin(), iterable.end());
Template parameters¶
iterable_type: The type of iterable object.
Parameters¶
iterable: An iterable object.
Complexity¶
Linear in the size of iterable plus linear in the size of the list if causes reallocation, linear in the size of iterable otherwise.
Example¶
#include <pypp/builtins/list.hpp>
#include <pypp/builtins/print.hpp>
int main()
{
py::list<int> list = {0, 1};
py::print(list);
list.extend(py::list<int>(2, 3));
py::print(list);
}
Output:
{0, 1}
{0, 1, 2, 3}