diff options
| author | Michael Bebenita <[email protected]> | 2010-09-07 18:18:37 -0700 |
|---|---|---|
| committer | Michael Bebenita <[email protected]> | 2010-09-07 18:41:08 -0700 |
| commit | b03812af2b65a31c567945a1c41515602ff92c20 (patch) | |
| tree | 356d9feffe19d4ad91d4525f2d6b6083269db442 /src/rt/util/array_list.h | |
| parent | Added "new" inline operators to memory regions. (diff) | |
| download | rust-b03812af2b65a31c567945a1c41515602ff92c20.tar.xz rust-b03812af2b65a31c567945a1c41515602ff92c20.zip | |
Change signature of array_list::pop().
Diffstat (limited to 'src/rt/util/array_list.h')
| -rw-r--r-- | src/rt/util/array_list.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/rt/util/array_list.h b/src/rt/util/array_list.h index 929117f3..d44111e8 100644 --- a/src/rt/util/array_list.h +++ b/src/rt/util/array_list.h @@ -15,7 +15,7 @@ public: size_t size(); int32_t append(T value); int32_t push(T value); - T pop(); + bool pop(T *value); bool replace(T old_value, T new_value); int32_t index_of(T value); bool is_empty(); @@ -54,10 +54,17 @@ array_list<T>::push(T value) { return _size - 1; } -template<typename T> T -array_list<T>::pop() { - T value = _data[-- _size]; - return value; +template<typename T> bool +array_list<T>::pop(T *value) { + if (_size == 0) { + return false; + } + if (value != NULL) { + *value = _data[-- _size]; + } else { + -- _size; + } + return true; } /** |