Implement Remove function for UniquePtrList.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
ad2d3be7e4
commit
5196bed8aa
|
@ -33,7 +33,7 @@ namespace ArbUt {
|
||||||
|
|
||||||
inline BorrowedPtr<ValueT> At(size_t index) const {
|
inline BorrowedPtr<ValueT> At(size_t index) const {
|
||||||
#ifndef NO_ASSERT
|
#ifndef NO_ASSERT
|
||||||
if (index >= _vector.size() || index < 0) {
|
if (index >= _vector.size()) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Index " << index << " is out of bounds.";
|
ss << "Index " << index << " is out of bounds.";
|
||||||
throw std::logic_error(ss.str());
|
throw std::logic_error(ss.str());
|
||||||
|
@ -42,6 +42,19 @@ namespace ArbUt {
|
||||||
return _vector[index];
|
return _vector[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void Remove(size_t index){
|
||||||
|
#ifndef NO_ASSERT
|
||||||
|
if (index >= _vector.size()) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Index " << index << " is out of bounds.";
|
||||||
|
throw std::logic_error(ss.str());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
auto item = _vector.at(index);
|
||||||
|
delete item;
|
||||||
|
_vector.erase(index);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool Contains(const BorrowedPtr<ValueT>& value) const {
|
inline bool Contains(const BorrowedPtr<ValueT>& value) const {
|
||||||
return std::find(_vector.begin(), _vector.end(), value) != _vector.end();
|
return std::find(_vector.begin(), _vector.end(), value) != _vector.end();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue