19 |
19 |
20 def __lt__(self, other): |
20 def __lt__(self, other): |
21 raise NotImplementedError |
21 raise NotImplementedError |
22 |
22 |
23 def insert_after(self, ev): |
23 def insert_after(self, ev): |
24 if not self.next: |
24 if not self.next or ev<self.next: |
25 ev.prev=self |
|
26 self.next=ev |
|
27 ev.next=None |
|
28 elif ev<self.next: |
|
29 self.insert_immediately_after(ev) |
25 self.insert_immediately_after(ev) |
30 else: |
26 else: |
31 self.next.insert_after(ev) |
27 self.next.insert_after(ev) |
32 |
28 |
33 def insert_immediately_after(self, ev): |
29 def insert_immediately_after(self, ev): |
|
30 assert(ev.next is None and ev.prev is None) |
34 ev.prev=self |
31 ev.prev=self |
35 ev.next=self.next |
32 ev.next=self.next |
36 if ev.next: |
|
37 ev.next.prev=ev |
|
38 self.next=ev |
33 self.next=ev |
|
34 |
|
35 def insert_immediately_before(self, ev): |
|
36 assert(ev.next is None and ev.prev is None) |
|
37 ev.next=self |
|
38 ev.prev=self.prev |
|
39 self.prev=ev |
39 |
40 |
40 def unlink(self): |
41 def unlink(self): |
41 n=self.next |
42 n=self.next |
42 p=self.prev |
43 p=self.prev |
43 if n: |
44 if n: |