Python builtin - add indexing support to std::unordered_set
This commit is contained in:
parent
05d6717de9
commit
146998ce81
2 changed files with 3 additions and 0 deletions
|
|
@ -38,6 +38,7 @@ for x in [cpp11_hash_tables.SetInt([1]),
|
||||||
cpp11_hash_tables.UnorderedMultiSetInt([1])]:
|
cpp11_hash_tables.UnorderedMultiSetInt([1])]:
|
||||||
|
|
||||||
swig_assert_equal([e for e in x], [1])
|
swig_assert_equal([e for e in x], [1])
|
||||||
|
swig_assert_equal(x[0], 1)
|
||||||
|
|
||||||
swig_assert_equal(1 in x, True)
|
swig_assert_equal(1 in x, True)
|
||||||
swig_assert_equal(2 in x, False)
|
swig_assert_equal(2 in x, False)
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,10 @@
|
||||||
|
|
||||||
#if defined(SWIGPYTHON_BUILTIN)
|
#if defined(SWIGPYTHON_BUILTIN)
|
||||||
%feature("python:slot", "sq_contains", functype="objobjproc") __contains__;
|
%feature("python:slot", "sq_contains", functype="objobjproc") __contains__;
|
||||||
|
%feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
%extend {
|
%extend {
|
||||||
void append(value_type x) {
|
void append(value_type x) {
|
||||||
self->insert(x);
|
self->insert(x);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue