1
/* -----------------------------------------------------------------------------
2
* See the LICENSE file for information on copyright, usage and redistribution
3
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
6
* ----------------------------------------------------------------------------- */
8
%include <std_common.i>
17
template<class T> class vector {
19
typedef size_t size_type;
21
typedef const value_type& const_reference;
24
size_type size() const;
25
size_type capacity() const;
26
void reserve(size_type n);
28
%rename(push) push_back;
29
void push_back(const value_type& x);
31
bool is_empty() const {
32
return $self->empty();
34
T pop() throw (std::out_of_range) {
35
if (self->size() == 0)
36
throw std::out_of_range("pop from empty vector");
41
const_reference get(int i) throw (std::out_of_range) {
42
int size = int(self->size());
46
throw std::out_of_range("vector index out of range");
48
void set(int i, const value_type& val) throw (std::out_of_range) {
49
int size = int(self->size());
53
throw std::out_of_range("vector index out of range");
58
// bool specialization
59
template<> class vector<bool> {
61
typedef size_t size_type;
62
typedef bool value_type;
63
typedef bool const_reference;
66
size_type size() const;
67
size_type capacity() const;
68
void reserve(size_type n);
70
%rename(push) push_back;
71
void push_back(const value_type& x);
73
bool is_empty() const {
74
return $self->empty();
76
bool pop() throw (std::out_of_range) {
77
if (self->size() == 0)
78
throw std::out_of_range("pop from empty vector");
79
bool x = self->back();
83
const_reference get(int i) throw (std::out_of_range) {
84
int size = int(self->size());
88
throw std::out_of_range("vector index out of range");
90
void set(int i, const value_type& val) throw (std::out_of_range) {
91
int size = int(self->size());
95
throw std::out_of_range("vector index out of range");
101
%define specialize_std_vector(T)
102
#warning "specialize_std_vector - specialization for type T no longer needed"