source: trunk/FACT++/dim_v19r19/dim/dllist.hxx@ 10492

Last change on this file since 10492 was 10480, checked in by tbretz, 14 years ago
New version V19r19 with some important bug fixes.
File size: 1.6 KB
Line 
1#ifndef __DLLHHDEFS
2#define __DLLHHDEFS
3
4class DllExp DLLItem {
5 friend class DLList ;
6 DLLItem *next;
7 DLLItem *prev;
8public:
9 DLLItem(){
10 next = 0;
11 prev = 0;
12 };
13};
14
15class DllExp DLList {
16 DLLItem *head;
17 DLLItem *curr;
18public:
19 DLList (){
20 DISABLE_AST
21 head = new DLLItem();
22 head->next = head;
23 head->prev = head;
24 curr = head;
25 ENABLE_AST
26 }
27 ~DLList()
28 {
29 DISABLE_AST
30 delete head;
31 ENABLE_AST
32 }
33 void add(DLLItem *item)
34 {
35 DLLItem *prevp;
36 DISABLE_AST
37 item->next = head;
38 prevp = head->prev;
39 item->prev = prevp;
40 prevp->next = item;
41 head->prev = item;
42 ENABLE_AST
43 }
44 DLLItem *getHead()
45 {
46 DISABLE_AST
47 if(head->next == head)
48 {
49 ENABLE_AST
50 return((DLLItem *)0);
51 }
52 curr = head->next;
53 ENABLE_AST
54 return( head->next );
55 }
56 DLLItem *getLast()
57 {
58 DISABLE_AST
59 if(head->prev == head)
60 {
61 ENABLE_AST
62 return((DLLItem *)0);
63 }
64 curr = head->prev;
65 ENABLE_AST
66 return( head->prev );
67 }
68 DLLItem *getNext()
69 {
70 DISABLE_AST
71 curr = curr->next;
72 if(curr == head)
73 {
74 ENABLE_AST
75 return((DLLItem *)0);
76 }
77 ENABLE_AST
78 return( curr );
79 }
80 DLLItem *removeHead()
81 {
82 DLLItem *item;
83 DISABLE_AST
84 item = head->next;
85 if(item == head)
86 {
87 ENABLE_AST
88 return((DLLItem *)0);
89 }
90 remove(item);
91 ENABLE_AST
92 return(item);
93 }
94 void remove(DLLItem *item)
95 {
96 DLLItem *prevp, *nextp;
97 DISABLE_AST
98 prevp = item->prev;
99 nextp = item->next;
100 prevp->next = item->next;
101 nextp->prev = prevp;
102 ENABLE_AST
103 }
104};
105#endif
Note: See TracBrowser for help on using the repository browser.