Remove all unused methods from IdList and its iterator

Fix gcc warning -Wreorder-ctor
 https://stackoverflow.com/questions/1828037/whats-the-point-of-g-wreorder
pull/1040/head
ruevs 2021-04-06 15:55:47 +03:00 committed by phkahler
parent 034d9213f1
commit 3e01afa3ae
1 changed files with 6 additions and 41 deletions

View File

@ -421,21 +421,8 @@ public:
T &operator*() const noexcept { return *elem; } T &operator*() const noexcept { return *elem; }
const T *operator->() const noexcept { return elem; } const T *operator->() const noexcept { return elem; }
T &operator=(const T &e) const noexcept {
*elem = e;
return *this;
}
T &operator=(const H h) const noexcept {
elem->h = e;
return *this;
}
bool operator==(const iterator &p) const { return p.position == position; } bool operator==(const iterator &p) const { return p.position == position; }
bool operator<(const iterator &p) const { return position < p.position; }
bool operator!=(const iterator &p) const { return !operator==(p); } bool operator!=(const iterator &p) const { return !operator==(p); }
bool operator>(const iterator &p) const { return operator!=(p) && !operator<(p); }
bool operator>=(const iterator &p) const { return !operator<(p); }
bool operator<=(const iterator &p) const { return !operator>(p); }
iterator &operator++() { iterator &operator++() {
++position; ++position;
@ -446,26 +433,20 @@ public:
} }
return *this; return *this;
} }
iterator &operator--() {
--position; // Needed for std:find_if of gcc used in entity.cpp GenerateEquations
if(0 > position) { difference_type operator-(const iterator &rhs) const noexcept {
elem = nullptr; // PAR@@@@ Remove just debugging return position - rhs.position;
} else if(position < list->elemidx.size()) {
elem = &(list->elemstore[list->elemidx[position]]);
}
return *this;
} }
iterator(IdList<T, H> *l) : list(l), position(0) { iterator(IdList<T, H> *l) : position(0), list(l) {
if(list) { if(list) {
if(list->elemstore.size() && list->elemidx.size()) { if(list->elemstore.size() && list->elemidx.size()) {
elem = &(list->elemstore[list->elemidx[position]]); elem = &(list->elemstore[list->elemidx[position]]);
} }
} }
}; };
iterator(const iterator &iter) iterator(IdList<T, H> *l, int pos) : position(pos), list(l) {
: list(iter.list), position(iter.position), elem(iter.elem){};
iterator(IdList<T, H> *l, int pos) : list(l), position(pos) {
if(position >= (int)list->elemidx.size()) { if(position >= (int)list->elemidx.size()) {
elem = nullptr; elem = nullptr;
} else if(0 <= position) { } else if(0 <= position) {
@ -503,16 +484,6 @@ public:
return t->h; return t->h;
} }
int LowerBoundIndex(T const& t) {
if(IsEmpty()) {
return 0;
}
auto it = std::lower_bound(elemptr.begin(), elemptr.end(), t, Compare(this));
auto idx = std::distance(elemidx.begin(), it);
auto i = static_cast<int>(idx);
return i;
}
void ReserveMore(int howMuch) { void ReserveMore(int howMuch) {
elemstore.reserve(elemstore.size() + howMuch); elemstore.reserve(elemstore.size() + howMuch);
elemidx.reserve(elemidx.size() + howMuch); elemidx.reserve(elemidx.size() + howMuch);
@ -572,16 +543,10 @@ public:
} }
T &Get(size_t i) { return elemstore[elemidx[i]]; } T &Get(size_t i) { return elemstore[elemidx[i]]; }
T const &Get(size_t i) const { return elemstore[elemidx[i]]; }
T &operator[](size_t i) { return Get(i); } T &operator[](size_t i) { return Get(i); }
T const &operator[](size_t i) const { return Get(i); }
iterator begin() { return IsEmpty() ? nullptr : iterator(this); } iterator begin() { return IsEmpty() ? nullptr : iterator(this); }
iterator end() { return IsEmpty() ? nullptr : iterator(this, elemidx.size()); } iterator end() { return IsEmpty() ? nullptr : iterator(this, elemidx.size()); }
const iterator begin() const { return IsEmpty() ? nullptr : iterator(this); }
const iterator end() const { return IsEmpty() ? nullptr : iterator(this, elemidx.size()); }
const iterator cbegin() const { return begin(); }
const iterator cend() const { return end(); }
void ClearTags() { void ClearTags() {
for(auto &elt : *this) { elt.tag = 0; } for(auto &elt : *this) { elt.tag = 0; }