Add feature 85117: [liboscar/icq] password changing support for ICQ.
[kdenetwork.git] / lanbrowsing / lisa / stringlist.cpp
blob3bf82f9c17eb1d6479dd073f5ba2a7966764525a
1 #include "simplelist.h"
3 template <class T>
4 SimpleList<T>::SimpleList()
5 :m_list(0)
6 ,m_current(0)
7 ,m_last(0)
8 ,m_size(0)
9 {};
11 template <class T>
12 SimpleList<T>::~SimpleList()
14 clear();
17 template <class T>
18 void SimpleList<T>::append(const T& text)
20 if (m_list==0)
22 m_list=new TemplNode<T>(text);
23 m_last=m_list;
25 else
27 m_last->m_next=new TemplNode<T>(text);
28 m_last=m_last->m_next;
30 m_size++;
33 template <class T>
34 void SimpleList<T>::removeFirst()
36 if (m_list==0) return;
37 TemplNode<T> *first=m_list;
38 m_list=m_list->m_next;
39 m_size--;
40 if (m_list==0)
41 m_last=0;
42 m_current=0;
43 delete first;
46 template <class T>
47 void SimpleList<T>::clear()
49 while (m_list!=0)
50 removeFirst();
51 m_current=0;
52 m_last=0;
53 m_list=0;
54 m_size=0;
57 template <class T>
58 void SimpleList<T>::remove(T* item)
60 if (item==0) return;
61 TemplNode<T>* pre(0);
62 for (T* tmp=first(); tmp!=0; tmp=next())
64 if (tmp==item)
66 if (m_current==m_list)
68 removeFirst();
69 return;
71 else
73 TemplNode<T> *succ=m_current->m_next;
74 if (m_current==m_last)
75 m_last=pre;
76 delete m_current;
77 pre->m_next=succ;
78 m_size--;
79 m_current=0;
83 pre=m_current;
88 template <class T>
89 T* SimpleList<T>::first()
91 m_current=m_list;
92 if (m_list==0)
93 return 0;
94 return &m_current->m_item;
97 template <class T>
98 T* SimpleList<T>::next()
100 if (m_current==0) return 0;
101 m_current=m_current->m_next;
102 if (m_current==0) return 0;
103 return &m_current->m_item;
106 template <class T>
107 int SimpleList<T>::size()
109 return m_size;