diff options
Diffstat (limited to 'Lib/java/std_vector.i')
-rw-r--r-- | Lib/java/std_vector.i | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 92fa25ac2..29439606b 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -46,6 +46,40 @@ namespace std { } } }; + + // bool specialization + template<> class vector<bool> { + public: + typedef size_t size_type; + typedef bool value_type; + typedef bool const_reference; + vector(); + vector(size_type n); + size_type size() const; + size_type capacity() const; + void reserve(size_type n); + %rename(isEmpty) empty; + bool empty() const; + void clear(); + %rename(add) push_back; + void push_back(const value_type& x); + %extend { + const_reference get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, const value_type& val) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = val; + else + throw std::out_of_range("vector index out of range"); + } + } + }; } %define specialize_std_vector(T) |