Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
vecbool.cpp
Go to the documentation of this file.
1
43#define _RWSTD_LIB_SRC
44
45#include <vector>
46#include <rw/_relops.h>
47#include <rw/_defs.h>
48
49
50#if !defined (_RWSTD_NO_BOOL) && !defined (_RWSTD_NO_VECTOR_BOOL)
51
52# if defined (_RWSTD_NO_CLASS_PARTIAL_SPEC)
53
54 // Duplicates of the following functions exist in include/vector.cc.
55 // Which set is used depends on the availability of partial specialization.
56
58
59
60void vector<bool, allocator<bool> >::flip ()
61{
62 _USING (namespace rel_ops);
63
64 for (iterator __i = begin(); __i != end(); __i++)
65 *__i = !*__i;
66}
67
68
69void vector<bool, allocator<bool> >::
70swap (vector<bool, allocator<bool> >::reference __x,
71 vector<bool, allocator<bool> >::reference __y)
72{
73 const bool __tmp = __x;
74 __x = __y;
75 __y = __tmp;
76}
77
78
79void vector<bool, allocator<bool> >::
80_C_insert (iterator pos, bool __x)
81{
82 if (_C_end._C_p != _C_bufend) {
83 _C_copy_backward(pos, _C_end - 1, _C_end);
84 *pos = __x;
85 ++_C_end;
86 }
87 else
88 {
89 size_type __len = size() ? 2 * size() : _RWSTD_WORD_BIT;
90 unsigned int* __q = _C_bit_alloc(__len);
91 iterator __i = _C_copy(begin(), pos, iterator(__q, 0));
92 *__i++ = __x;
93 _C_end = _C_copy(pos, end(), __i);
94 _C_value_alloc_type (*this).
95 deallocate(_C_begin._C_p,_C_bufend-_C_begin._C_p);
96 _C_bufend = __q + (__len + _RWSTD_WORD_BIT - 1)/_RWSTD_WORD_BIT;
97 _C_begin = iterator(__q, 0);
98 }
99}
100
101
102void vector<bool, allocator<bool> >::
103insert (iterator pos, size_type __n, const bool& __x)
104{
105 if (__n == 0)
106 return;
107
108 if (capacity() - size() >= __n) {
109 _C_copy_backward(pos, end(), _C_end + __n);
110 _C_fill(pos, pos + __n, __x);
111 _C_end += __n;
112 }
113 else {
114 size_type __len = size() + max(size(), __n);
115 unsigned int* __q = _C_bit_alloc(__len);
116 iterator __i = _C_copy(begin(), pos, iterator(__q, 0));
117 _C_fill_n(__i, __n, __x);
118 _C_end = _C_copy(pos, end(), __i + __n);
119 _C_value_alloc_type (*this).
120 deallocate(_C_begin._C_p,_C_bufend-_C_begin._C_p);
121 _C_bufend = __q + (__n + _RWSTD_WORD_BIT - 1)/_RWSTD_WORD_BIT;
122 _C_begin = iterator(__q, 0);
123 }
124}
125
126
127void vector<bool, allocator<bool> >::
128resize (size_type __new_size, bool __c)
129{
130 if (__new_size > size())
131 insert(end(), __new_size - size(), __c);
132 else if (__new_size < size())
133 erase(begin() + __new_size, end());
134}
135
136
137} // namespace std
138
139
140# endif // _RWSTD_NO_CLASS_PARTIAL_SPEC
141#endif // !defined (_RWSTD_NO_BOOL) && !defined (_RWSTD_NO_VECTOR_BOOL)
#define pos
Definition 17.names.cpp:518
const int end
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
#define _USING(name)
Definition _defs.h:568
Definition json.h:5363
#define max(a, b)