@@ -18,28 +18,11 @@ enum dlist_node<T> = @{
18
18
mut next: dlist_link<T >
19
19
} ;
20
20
21
- class dlist_root<T > {
22
- let mut size: uint ;
23
- let mut hd: dlist_link < T > ;
24
- let mut tl: dlist_link < T > ;
25
- new ( ) {
26
- self . size = 0 ; self . hd = none; self . tl = none;
27
- }
28
- drop {
29
- /* FIXME (#3039) This doesn't work during task failure - the box
30
- * annihilator might have killed some of our nodes already. This will
31
- * be safe to uncomment when the box annihilator is safer. As is,
32
- * this makes test_dlist_cyclic_link below crash the runtime.
33
- // Empty the list. Not doing this explicitly would leave cyclic links
34
- // around, not to be freed until cycle collection at task exit.
35
- while self.hd.is_some() {
36
- self.unlink(self.hd.get());
37
- }
38
- */
39
- }
40
- }
41
-
42
- type dlist<T > = @dlist_root<T >;
21
+ enum dlist < T > = @{
22
+ mut size: uint,
23
+ mut hd: dlist_link <T >,
24
+ mut tl: dlist_link<T >,
25
+ } ;
43
26
44
27
impl private_methods < T > for dlist_node < T > {
45
28
pure fn assert_links ( ) {
@@ -107,7 +90,7 @@ pure fn new_dlist_node<T>(+data: T) -> dlist_node<T> {
107
90
108
91
/// Creates a new, empty dlist.
109
92
pure fn new_dlist < T > ( ) -> dlist < T > {
110
- @ unchecked { dlist_root ( ) }
93
+ dlist ( @ { mut size : 0 , mut hd : none , mut tl : none } )
111
94
}
112
95
113
96
/// Creates a new dlist with a single element
@@ -134,7 +117,7 @@ fn concat<T>(lists: dlist<dlist<T>>) -> dlist<T> {
134
117
result
135
118
}
136
119
137
- impl private_methods < T > for dlist_root < T > {
120
+ impl private_methods < T > for dlist < T > {
138
121
pure fn new_link ( -data : T ) -> dlist_link < T > {
139
122
some ( dlist_node ( @{ data: data, mut linked: true ,
140
123
mut prev: none, mut next: none} ) )
@@ -336,7 +319,7 @@ impl extensions<T> for dlist<T> {
336
319
* to the other list's head. O(1).
337
320
*/
338
321
fn append ( them : dlist < T > ) {
339
- if box:: ptr_eq ( self , them) {
322
+ if box:: ptr_eq ( * self , * them) {
340
323
fail ~"Cannot append a dlist to itself!"
341
324
}
342
325
if them.len() > 0 {
@@ -353,7 +336,7 @@ impl extensions<T> for dlist<T> {
353
336
* list's tail to this list's head. O(1).
354
337
*/
355
338
fn prepend(them: dlist<T>) {
356
- if box::ptr_eq(self, them) {
339
+ if box::ptr_eq(* self, * them) {
357
340
fail ~" Cannot prepend a dlist to itself!"
358
341
}
359
342
if them. len ( ) > 0 {
0 commit comments