1 #ifndef CPPAD_CG_CODE_HANDLER_VECTOR_INCLUDED 2 #define CPPAD_CG_CODE_HANDLER_VECTOR_INCLUDED 39 handler_->addVector(
this);
43 handler_(orig.handler_) {
44 handler_->addVector(
this);
48 if (handler_ !=
nullptr)
49 handler_->removeVector(
this);
70 template<
class Base,
class T>
73 using iterator =
typename std::vector<T>::iterator;
74 using const_iterator =
typename std::vector<T>::const_iterator;
75 using const_reverse_iterator =
typename std::vector<T>::const_reverse_iterator;
76 using reverse_iterator =
typename std::vector<T>::reverse_iterator;
77 using reference =
typename std::vector<T>::reference;
78 using const_reference =
typename std::vector<T>::const_reference;
99 inline void adjustSize() {
100 size_t s = this->handler_->getManagedNodesCount();
101 if (s >= data_.capacity()) {
102 data_.reserve(s * 3 / 2 + 1);
111 if (p == (std::numeric_limits<size_t>::max)())
112 throw CGException(
"An operation node is not managed by this code handler");
114 if (p >= data_.size())
122 if (p == (std::numeric_limits<size_t>::max)())
123 throw CGException(
"An operation node is not managed by this code handler");
124 CPPADCG_ASSERT_UNKNOWN(p < data_.size())
133 if (p == (std::numeric_limits<size_t>::max)())
134 throw CGException(
"An operation node is not managed by this code handler");
135 CPPADCG_ASSERT_UNKNOWN(p < data_.size())
142 CPPADCG_ASSERT_UNKNOWN(node.getCodeHandler() == this->handler_)
144 size_t p = node.getHandlerPosition();
145 if (p == (std::numeric_limits<size_t>::max)())
146 throw CGException(
"An operation node is not managed by this code handler");
147 CPPADCG_ASSERT_UNKNOWN(p < data_.size())
149 data_[node.getHandlerPosition()] = val;
152 inline size_t size()
const {
156 inline bool empty()
const {
157 return data_.empty();
160 inline void fill(
const T& v) {
161 std::fill(data_.begin(), data_.end(), v);
166 inline iterator begin() {
167 return data_.begin();
170 inline const_iterator begin()
const {
171 return data_.begin();
174 inline iterator end() {
178 inline const_iterator end()
const {
182 inline reverse_iterator rbegin() {
183 return data_.rbegin();
186 inline const_reverse_iterator rbegin()
const {
187 return data_.rbegin();
190 inline reverse_iterator rend() {
194 inline const_reverse_iterator rend()
const {
198 inline const_iterator cbegin()
const noexcept {
199 return data_.cbegin();
202 inline const_iterator cend()
const noexcept {
206 inline const_reverse_iterator crbegin()
const noexcept {
207 return data_.crbegin();
210 inline const_reverse_iterator crend()
const noexcept {
211 return data_.crend();
216 size_t end)
override {
217 if (start < data_.size()) {
218 end = std::min<size_t>(end, data_.size());
219 data_.erase(data_.begin() + start, data_.begin() + end);
virtual void nodesErased(size_t start, size_t end)=0
void nodesErased(size_t start, size_t end) override
size_t getHandlerPosition() const
reference operator[](const OperationNode< Base > &node)
CodeHandler< Base > * getCodeHandler() const