Instead of returning a bool (which everyone ignored) pop asserts

This commit is contained in:
Jesse Jones 2012-12-08 21:45:43 -08:00 committed by Brian Anderson
parent 6bab226fc5
commit eca23da98b
1 changed files with 3 additions and 6 deletions

View File

@ -35,7 +35,7 @@ public:
size_t size() const;
int32_t append(T value);
int32_t push(T value);
bool pop(T *value);
void pop(T *value);
bool replace(T old_value, T new_value);
int32_t index_of(T value) const;
bool is_empty() const;
@ -81,17 +81,14 @@ array_list<T>::push(T value) {
return _size - 1;
}
template<typename T> bool
template<typename T> void
array_list<T>::pop(T *value) {
if (_size == 0) {
return false;
}
assert(_size > 0);
if (value != NULL) {
*value = _data[-- _size];
} else {
-- _size;
}
return true;
}
/**