88 |
} RTEListNode; |
} RTEListNode; |
89 |
|
|
90 |
public: |
public: |
91 |
|
typedef RTEListNode* NodeHandle; |
92 |
|
|
93 |
RTEList (void) { |
RTEList (void) { |
94 |
// initialize alloclist fistnode and lastnode pointers |
// initialize alloclist fistnode and lastnode pointers |
95 |
firstnode.aprev=&firstnode; |
firstnode.aprev=&firstnode; |
145 |
return(&acurrentnode->data); |
return(&acurrentnode->data); |
146 |
} |
} |
147 |
|
|
148 |
|
/// Returns a handle for the currently selected node or NULL if the list is empty. |
149 |
|
inline NodeHandle current(void) { |
150 |
|
if (acurrentnode->anext == acurrentnode) return NULL; |
151 |
|
return acurrentnode; |
152 |
|
} |
153 |
|
|
154 |
|
/// Selects the node in the list respective to the node handle and returns it's data. |
155 |
|
inline T* set_current(NodeHandle hNode) { |
156 |
|
acurrentnode = (RTEListNode*) hNode; |
157 |
|
return &acurrentnode->data; |
158 |
|
//FIXME: there should be a check if the node could be selected and a return value of NULL if failed |
159 |
|
} |
160 |
|
|
161 |
|
/// Returns true if the list is empty. |
162 |
|
inline bool is_empty() { |
163 |
|
return !first(); |
164 |
|
} |
165 |
|
|
166 |
RTEListNode firstnode; |
RTEListNode firstnode; |
167 |
RTEListNode lastnode; |
RTEListNode lastnode; |
168 |
RTEListNode *acurrentnode; |
RTEListNode *acurrentnode; |
404 |
RTEListNode *prevelem; |
RTEListNode *prevelem; |
405 |
RTEListNode *nextelem; |
RTEListNode *nextelem; |
406 |
RTEListNode *node; |
RTEListNode *node; |
407 |
|
|
408 |
char *node_to_free=(char *)element; |
char *node_to_free=(char *)element; |
409 |
// calculate the offset of the RTEListNode (see free_offset calculation in the constructor) |
// calculate the offset of the RTEListNode (see free_offset calculation in the constructor) |
410 |
node_to_free -= free_offset; |
node_to_free -= free_offset; |
420 |
//printf("free returning elem=%d\n",¤tnode->data); |
//printf("free returning elem=%d\n",¤tnode->data); |
421 |
} |
} |
422 |
|
|
423 |
|
/// Selects the current element node by providing the pointer to the sought |
424 |
|
/// element's data. |
425 |
|
inline void set_current(T* element) { |
426 |
|
char* node = (char*) element; |
427 |
|
node -= free_offset; // calculate the offset of the RTEListNode (see free_offset calculation in the constructor) |
428 |
|
acurrentnode = (RTEListNode*) node; |
429 |
|
//FIXME: there should be a check if the element could be selected and a respective return value |
430 |
|
} |
431 |
|
|
432 |
|
/// Returns true if there's no allocated element. |
433 |
|
inline bool is_empty() { |
434 |
|
return !first(); |
435 |
|
} |
436 |
|
|
437 |
// empty the whole list |
// empty the whole list |
438 |
inline void empty(void) { |
inline void empty(void) { |
439 |
|
|