diff --git a/src/py/statiskit/stl/_stl.py b/src/py/statiskit/stl/_stl.py index e9fb1c1..e539fb5 100644 --- a/src/py/statiskit/stl/_stl.py +++ b/src/py/statiskit/stl/_stl.py @@ -18,20 +18,20 @@ __stl.std._Set_6436891c9b6854f494789a812891cbe5.KeyType = __stl.std._BasicString_448c20257e485acda59dc59305fceb58 __stl.std._Set_6436891c9b6854f494789a812891cbe5.ValueType = __stl.std._BasicString_448c20257e485acda59dc59305fceb58 __stl.std._UnorderedSet_d48105936d4f5d09a78d2aa9f878fdb8.KeyEqual = __stl.std._EqualTo_d0ba0922f2505f7b8e291326cad79af5 -__stl.statiskit.stl.SetLessDoubleGenerator = __stl.statiskit.stl._Generator_74bc331707c1505eb2f807cae7c32bbb -__stl.statiskit.stl.SetLessString = __stl.std._Set_6436891c9b6854f494789a812891cbe5 -__stl.statiskit.stl.SetLessStringGenerator = __stl.statiskit.stl._Generator_745e4933f5b250d9bc5232fe864d0cf7 +__stl.statiskit.stl.VectorInt = __stl.std._Vector_6b9ae5eac40858c9a0f5e6e21c15d1d3 +__stl.statiskit.stl.SetLessIntGenerator = __stl.statiskit.stl._Generator_e76a1308464d5a9a837d9a61f942fae7 __stl.statiskit.stl.SetLessIndexGenerator = __stl.statiskit.stl._Generator_10b14312eeb655268489cd34090870cf -__stl.statiskit.stl.SetIndex = __stl.std._UnorderedSet_d48105936d4f5d09a78d2aa9f878fdb8 __stl.statiskit.stl.SetLessIndex = __stl.std._Set_476c1c1f206251dba7af53c48f3f6e42 -__stl.statiskit.stl.SetLessIntGenerator = __stl.statiskit.stl._Generator_e76a1308464d5a9a837d9a61f942fae7 -__stl.statiskit.stl.SetIndexGenerator = __stl.statiskit.stl._Generator_3b59a0980c80518c808634f7a84dc3cd +__stl.statiskit.stl.SetLessStringGenerator = __stl.statiskit.stl._Generator_745e4933f5b250d9bc5232fe864d0cf7 +__stl.statiskit.stl.SetIndex = __stl.std._UnorderedSet_d48105936d4f5d09a78d2aa9f878fdb8 +__stl.statiskit.stl.SetLessString = __stl.std._Set_6436891c9b6854f494789a812891cbe5 __stl.statiskit.stl.VectorString = __stl.std._Vector_c047f2c3135554ceb57f166fd404cfc8 -__stl.statiskit.stl.SetLessInt = __stl.std._Set_882a8dd1e64a51b4a9da29ab852a852e __stl.statiskit.stl.SetLessDouble = __stl.std._Set_858bbf0613575e2ebe4b0e5902107ad6 -__stl.statiskit.stl.VectorDouble = __stl.std._Vector_107131f9768c56e794a9b0de728d1738 __stl.statiskit.stl.VectorIndex = __stl.std._Vector_dc5522842bc75d8b9ac7b46020c60854 +__stl.statiskit.stl.SetLessInt = __stl.std._Set_882a8dd1e64a51b4a9da29ab852a852e +__stl.statiskit.stl.SetLessDoubleGenerator = __stl.statiskit.stl._Generator_74bc331707c1505eb2f807cae7c32bbb +__stl.statiskit.stl.VectorDouble = __stl.std._Vector_107131f9768c56e794a9b0de728d1738 __stl.statiskit.stl.String = __stl.std._BasicString_448c20257e485acda59dc59305fceb58 -__stl.statiskit.stl.VectorInt = __stl.std._Vector_6b9ae5eac40858c9a0f5e6e21c15d1d3 +__stl.statiskit.stl.SetIndexGenerator = __stl.statiskit.stl._Generator_3b59a0980c80518c808634f7a84dc3cd __stl.statiskit.Indices = __stl.std._Set_476c1c1f206251dba7af53c48f3f6e42 __stl.std._Vector_c047f2c3135554ceb57f166fd404cfc8.ValueType = __stl.std._BasicString_448c20257e485acda59dc59305fceb58 diff --git a/src/py/statiskit/stl/set.py b/src/py/statiskit/stl/set.py index f6089df..2184ddc 100644 --- a/src/py/statiskit/stl/set.py +++ b/src/py/statiskit/stl/set.py @@ -27,6 +27,15 @@ def __init__(self, arg=None): cls.__init__ = wrapper__init__(cls.__init__) + # def __eq__(self, other): + # if isinstance(other, self.__class__): + # return all(self[index] == other[index] for index in range(len(self))) + # else: + # return False + + # cls.__eq__ = __eq__ + # del __eq__ + def __str__(self): return "{" + ", ".join(str(value) for value in self) + "}" diff --git a/src/py/statiskit/stl/vector.py b/src/py/statiskit/stl/vector.py index 7121c44..55a54fe 100644 --- a/src/py/statiskit/stl/vector.py +++ b/src/py/statiskit/stl/vector.py @@ -55,6 +55,15 @@ def __setitem__(self, index, value): return __getitem__, __setitem__ + def __eq__(self, other): + if isinstance(other, self.__class__): + return all(self[index] == other[index] for index in range(len(self))) + else: + return False + + cls.__eq__ = __eq__ + del __eq__ + cls.__getitem__, cls.__setitem__ = wrapper_at(cls.at) del cls.at diff --git a/src/py/wrapper/wrapper_8f249c2863945cb59771b97c53bdafec.cpp b/src/py/wrapper/wrapper_8f249c2863945cb59771b97c53bdafec.cpp index 339a379..7c6c0a3 100644 --- a/src/py/wrapper/wrapper_8f249c2863945cb59771b97c53bdafec.cpp +++ b/src/py/wrapper/wrapper_8f249c2863945cb59771b97c53bdafec.cpp @@ -26,7 +26,7 @@ void wrapper_8f249c2863945cb59771b97c53bdafec() boost::python::scope().attr("std") = module_a5e4e9231d6351ccb0e06756b389f0af; boost::python::scope scope_a5e4e9231d6351ccb0e06756b389f0af = module_a5e4e9231d6351ccb0e06756b389f0af; boost::python::class_< struct ::std::binary_function< unsigned long int, unsigned long int, bool >, autowig::Held< struct ::std::binary_function< unsigned long int, unsigned long int, bool > >::Type > class_8f249c2863945cb59771b97c53bdafec("_BinaryFunction_8f249c2863945cb59771b97c53bdafec", "", boost::python::no_init); - class_8f249c2863945cb59771b97c53bdafec.def(boost::python::init< struct ::std::binary_function< unsigned long int, unsigned long int, bool > const & >("")); class_8f249c2863945cb59771b97c53bdafec.def(boost::python::init< >("")); + class_8f249c2863945cb59771b97c53bdafec.def(boost::python::init< struct ::std::binary_function< unsigned long int, unsigned long int, bool > const & >("")); } \ No newline at end of file diff --git a/test/test_vector.py b/test/test_vector.py new file mode 100644 index 0000000..6af1ee1 --- /dev/null +++ b/test/test_vector.py @@ -0,0 +1,38 @@ +from statiskit import stl + +import unittest +from nose.plugins.attrib import attr + +@attr(linux=True, + osx=True, + win=True, + level=1) +class TestVector(unittest.TestCase): + + def test___initialization(self): + """Test vector initialization""" + + v = stl.VectorIndex() + self.assertEqual(len(v), 0) + + def test__equal(self): + """Test vectors equality""" + + v1 = stl.VectorIndex() + v1.push_back(3) + v1.push_back(1) + v1.push_back(2) + v2 = stl.VectorIndex() + v2.push_back(3) + v2.push_back(1) + v2.push_back(2) + self.assertEqual(v1, v2) + v3 = stl.VectorString() + v3.push_back('A') + v3.push_back('B') + v3.push_back('C') + v4 = stl.VectorString() + v4.push_back('A') + v4.push_back('B') + v4.push_back('C') + self.assertEqual(v3, v4) \ No newline at end of file