polymorphic indexed_list fixes:

1) indexed_list no longer has virtual methods. It's not actually subclassed
and there is very rarely good reason to subclass collection classes.
2) Added a virtual dtor to indexed_list_object which is intended to be
subclassed. This allows derived dtors to be called if the object is
deleted with a indexed_list_object*.
This commit is contained in:
Jesse Jones 2012-12-08 20:12:12 -08:00 committed by Brian Anderson
parent fc740a7297
commit cf1c3d2da0
1 changed files with 10 additions and 9 deletions

View File

@ -17,6 +17,7 @@
class indexed_list_object {
public:
virtual ~indexed_list_object() {}
int32_t list_index;
};
@ -39,22 +40,22 @@ public:
template<typename T> class indexed_list {
array_list<T*> list;
public:
virtual int32_t append(T *value);
virtual bool pop(T **value);
int32_t append(T *value);
bool pop(T **value);
/**
* Same as pop(), except that it returns NULL if the list is empty.
*/
virtual T* pop_value();
virtual size_t length() const {
T* pop_value();
size_t length() const {
return list.size();
}
virtual bool is_empty() const {
bool is_empty() const {
return list.is_empty();
}
virtual int32_t remove(T* value);
virtual T * operator[](int32_t index);
virtual const T * operator[](int32_t index) const;
virtual ~indexed_list() {}
int32_t remove(T* value);
T * operator[](int32_t index);
const T * operator[](int32_t index) const;
~indexed_list() {}
};
template<typename T> int32_t