Skip to content

Commit ba2a2ff

Browse files
TheMarexPatrick Niklaus
authored andcommitted
Remove RemoveIterator because its dangerous
1 parent 9b87b8b commit ba2a2ff

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

include/util/deallocating_vector.hpp

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -183,57 +183,6 @@ class DeallocatingVectorIterator
183183
}
184184
};
185185

186-
template <typename ElementT, std::size_t ELEMENTS_PER_BLOCK>
187-
class DeallocatingVectorRemoveIterator
188-
: public boost::iterator_facade<DeallocatingVectorRemoveIterator<ElementT, ELEMENTS_PER_BLOCK>,
189-
ElementT,
190-
boost::forward_traversal_tag>
191-
{
192-
DeallocatingVectorIteratorState<ElementT> current_state;
193-
194-
public:
195-
DeallocatingVectorRemoveIterator(std::size_t idx, std::vector<ElementT *> *input_list)
196-
: current_state(idx, input_list)
197-
{
198-
}
199-
200-
friend class boost::iterator_core_access;
201-
202-
void increment()
203-
{
204-
const std::size_t old_bucket = current_state.index / ELEMENTS_PER_BLOCK;
205-
206-
++current_state.index;
207-
const std::size_t new_bucket = current_state.index / ELEMENTS_PER_BLOCK;
208-
if (old_bucket != new_bucket)
209-
{
210-
// delete old bucket entry
211-
if (nullptr != current_state.bucket_list->at(old_bucket))
212-
{
213-
delete[] current_state.bucket_list->at(old_bucket);
214-
current_state.bucket_list->at(old_bucket) = nullptr;
215-
}
216-
}
217-
}
218-
219-
bool equal(DeallocatingVectorRemoveIterator const &other) const
220-
{
221-
return current_state.index == other.current_state.index;
222-
}
223-
224-
std::ptrdiff_t distance_to(DeallocatingVectorRemoveIterator const &other) const
225-
{
226-
return other.current_state.index - current_state.index;
227-
}
228-
229-
ElementT &dereference() const
230-
{
231-
const std::size_t current_bucket = current_state.index / ELEMENTS_PER_BLOCK;
232-
const std::size_t current_index = current_state.index % ELEMENTS_PER_BLOCK;
233-
return (current_state.bucket_list->at(current_bucket)[current_index]);
234-
}
235-
};
236-
237186
template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs);
238187

239188
template <typename ElementT> class DeallocatingVector
@@ -247,9 +196,6 @@ template <typename ElementT> class DeallocatingVector
247196
using iterator = DeallocatingVectorIterator<ElementT, ELEMENTS_PER_BLOCK>;
248197
using const_iterator = ConstDeallocatingVectorIterator<ElementT, ELEMENTS_PER_BLOCK>;
249198

250-
// this forward-only iterator deallocates all buckets that have been visited
251-
using deallocation_iterator = DeallocatingVectorRemoveIterator<ElementT, ELEMENTS_PER_BLOCK>;
252-
253199
DeallocatingVector() : current_size(0)
254200
{
255201
bucket_list.emplace_back(new ElementT[ELEMENTS_PER_BLOCK]);
@@ -368,13 +314,6 @@ template <typename ElementT> class DeallocatingVector
368314

369315
iterator end() { return iterator(size(), &bucket_list); }
370316

371-
deallocation_iterator dbegin()
372-
{
373-
return deallocation_iterator(static_cast<std::size_t>(0), &bucket_list);
374-
}
375-
376-
deallocation_iterator dend() { return deallocation_iterator(size(), &bucket_list); }
377-
378317
const_iterator begin() const
379318
{
380319
return const_iterator(static_cast<std::size_t>(0), &bucket_list);

0 commit comments

Comments
 (0)