Implement Remove function for UniquePtrList.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-06-02 13:57:40 +02:00
parent ad2d3be7e4
commit 5196bed8aa
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 14 additions and 1 deletions

View File

@ -33,7 +33,7 @@ namespace ArbUt {
inline BorrowedPtr<ValueT> At(size_t index) const {
#ifndef NO_ASSERT
if (index >= _vector.size() || index < 0) {
if (index >= _vector.size()) {
std::stringstream ss;
ss << "Index " << index << " is out of bounds.";
throw std::logic_error(ss.str());
@ -42,6 +42,19 @@ namespace ArbUt {
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 {
return std::find(_vector.begin(), _vector.end(), value) != _vector.end();
}