#include "mymemory.h"
typedef unsigned int uint;
-
template<typename _Tp>
class mllnode {
public:
uint _size;
};
+class actionlist;
+
template<typename _Tp>
class sllnode {
public:
_Tp val;
template<typename T>
friend class SnapList;
+ friend class actionlist;
};
template<typename _Tp>
_size++;
}
- sllnode<_Tp>add_front(_Tp val) {
+ sllnode<_Tp>* add_front(_Tp val) {
sllnode<_Tp> * tmp = new sllnode<_Tp>();
tmp->prev = NULL;
tmp->next = head;
_size=0;
}
- void insertAfter(sllnode<_Tp> * node, _Tp val) {
+ sllnode<_Tp> * insertAfter(sllnode<_Tp> * node, _Tp val) {
sllnode<_Tp> *tmp = new sllnode<_Tp>();
tmp->val = val;
tmp->prev = node;
tmp->next->prev = tmp;
}
_size++;
+ return tmp;
}
void insertBefore(sllnode<_Tp> * node, _Tp val) {
_size(_capacity),
capacity(_capacity),
array((type *) model_malloc(sizeof(type) * _capacity)) {
- memcpy(array, _array, capacity * sizeof(type));
+ real_memcpy(array, _array, capacity * sizeof(type));
}
void pop_back() {
_size--;
_size(_capacity),
capacity(_capacity),
array((type *) snapshot_malloc(sizeof(type) * _capacity)) {
- memcpy(array, _array, capacity * sizeof(type));
+ real_memcpy(array, _array, capacity * sizeof(type));
}
void pop_back() {
_size--;
array[index] = item;
}
+ void remove(type item) {
+ for(uint i = 0;i < _size;i++) {
+ if (at(i) == item) {
+ removeAt(i);
+ return;
+ }
+ }
+ }
+
void removeAt(uint index) {
for (uint i = index;(i + 1) < _size;i++) {
set(i, at(i + 1));