removal from the front >>> d = LinkedDeque() >>> d.is_empty() True >>> d.remove_first() Traceback (most recent call last): ... IndexError: remove_first from empty list >>> d.add_first('A') # doctest: +ELLIPSIS <data_structure
(self)
| 103 | # DEqueu Remove Operations (At the front, At the end) |
| 104 | |
| 105 | def remove_first(self): |
| 106 | """removal from the front |
| 107 | >>> d = LinkedDeque() |
| 108 | >>> d.is_empty() |
| 109 | True |
| 110 | >>> d.remove_first() |
| 111 | Traceback (most recent call last): |
| 112 | ... |
| 113 | IndexError: remove_first from empty list |
| 114 | >>> d.add_first('A') # doctest: +ELLIPSIS |
| 115 | <data_structures.linked_list.deque_doubly.LinkedDeque object at ... |
| 116 | >>> d.remove_first() |
| 117 | 'A' |
| 118 | >>> d.is_empty() |
| 119 | True |
| 120 | """ |
| 121 | if self.is_empty(): |
| 122 | raise IndexError("remove_first from empty list") |
| 123 | return self._delete(self._header._next) |
| 124 | |
| 125 | def remove_last(self): |
| 126 | """removal in the end |