00001
00002
00003
00004 #ifndef _XVLIST_H_
00005 #define _XVLIST_H_
00006
00016 class XVNode {
00017
00018 public:
00019
00020 XVNode * succ;
00021
00022 XVNode() { succ = NULL; };
00023 };
00024
00025 class XVList {
00026
00027 protected:
00028
00029 int count;
00030 XVNode *head;
00031
00032 public:
00033
00034 XVList() { head=NULL; count=0; };
00035
00036 int list_length() { return count; }
00037
00038 void append(XVNode * new_node) {
00039
00040 XVNode * ptr = head;
00041 count++;
00042 new_node->succ = NULL;
00043 if(!head){ head = new_node; return; }
00044 while( ptr->succ ) { ptr = (ptr->succ); }
00045 ptr->succ = new_node;
00046 };
00047
00048 void remove(XVNode * rem_node) {
00049
00050 XVNode *ptr=head;
00051 if(head == rem_node){
00052 head = head->succ;
00053 count--;
00054 return;
00055 }
00056
00057 while(ptr && ptr->succ != rem_node)
00058 ptr = ptr->succ;
00059
00060 if(ptr){
00061 ptr->succ = (ptr->succ)->succ;
00062 count--;
00063 }
00064 };
00065
00066 bool contains(XVNode * check) {
00067
00068 XVNode * ptr = head;
00069 while( ptr ) {
00070 if( ptr == check ) return true;
00071 ptr = ptr->succ;
00072 }
00073 return false;
00074 };
00075
00076 bool empty() { return count > 0 ? false : true; };
00077 };
00078
00079 #endif