From b03812af2b65a31c567945a1c41515602ff92c20 Mon Sep 17 00:00:00 2001 From: Michael Bebenita Date: Tue, 7 Sep 2010 18:18:37 -0700 Subject: Change signature of array_list::pop(). --- src/rt/util/array_list.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/rt/util/array_list.h') 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::push(T value) { return _size - 1; } -template T -array_list::pop() { - T value = _data[-- _size]; - return value; +template bool +array_list::pop(T *value) { + if (_size == 0) { + return false; + } + if (value != NULL) { + *value = _data[-- _size]; + } else { + -- _size; + } + return true; } /** -- cgit v1.2.3