1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#ifndef __LINKEDLIST_H_
#define __LINKEDLIST_H_
template<class TYPE>
class LinkedNode
{
public:
// LinkedNode(TYPE *the_data);
/* these all were embedded functions in the header, but since these type
have been misbehaving, I took these out. Documentation later. */
/* I put thse functions back there since this caused some problems
and prevented this package to build on hppa -- Benjamin Drieu
<benj@debian.org> via maintainer */
LinkedNode<TYPE>::LinkedNode(TYPE *the_data)
{
data = the_data;
next = prev = NULL;
}
void set_data(TYPE *the_data);
TYPE *get_data();
void del_data();
void set_next(LinkedNode<TYPE> *nextnode);
void set_prev(LinkedNode<TYPE> *prevnode);
LinkedNode *get_next();
LinkedNode *get_prev();
private:
TYPE *data;
LinkedNode<TYPE> *next;
LinkedNode<TYPE> *prev;
};
template<class TYPE>
class cur_ptr {
public:
/* I put thse functions back there since this caused some problems
and prevented this package to build on hppa -- Benjamin Drieu
<benj@debian.org> */
//cur_ptr();
//~cur_ptr();
cur_ptr<TYPE>::cur_ptr()
{
current = NULL;
next = NULL;
}
cur_ptr<TYPE>::~cur_ptr()
{
}
LinkedNode<TYPE> *current;
cur_ptr *next;
};
template<class TYPE>
class LinkedList
{
public:
LinkedList();
~LinkedList();
void clr_list();
int add_tail_entry(TYPE *new_entry);
int add_entry(TYPE *new_entry);
int del_entry(TYPE *entry);
int del_cur_entry();
void reset_current();
int push_current();
int pop_current();
TYPE *get_next();
TYPE *get_prev();
TYPE *get_first();
void set_del_data();
int get_mem_size();
int get_mem_size_dynamic();
int get_mem_size_linkedlist();
private:
LinkedNode<TYPE> *root;
cur_ptr<TYPE> *cur_list;
int del_data; // Should data be deleted when the entry is? Default no
};
#endif
|