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:
parent
fc740a7297
commit
cf1c3d2da0
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user