data_structures.linked_list.deque_doubly ======================================== .. py:module:: data_structures.linked_list.deque_doubly .. autoapi-nested-parse:: Implementing Deque using DoublyLinkedList ... Operations: 1. insertion in the front -> O(1) 2. insertion in the end -> O(1) 3. remove from the front -> O(1) 4. remove from the end -> O(1) Classes ------- .. autoapisummary:: data_structures.linked_list.deque_doubly.LinkedDeque data_structures.linked_list.deque_doubly._DoublyLinkedBase Module Contents --------------- .. py:class:: LinkedDeque Bases: :py:obj:`_DoublyLinkedBase` A Private class (to be inherited) .. py:method:: add_first(element) insertion in the front >>> LinkedDeque().add_first('AV').first() 'AV' .. py:method:: add_last(element) insertion in the end >>> LinkedDeque().add_last('B').last() 'B' .. py:method:: first() return first element >>> d = LinkedDeque() >>> d.add_first('A').first() 'A' >>> d.add_first('B').first() 'B' .. py:method:: last() return last element >>> d = LinkedDeque() >>> d.add_last('A').last() 'A' >>> d.add_last('B').last() 'B' .. py:method:: remove_first() 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 >> d.remove_first() 'A' >>> d.is_empty() True .. py:method:: remove_last() removal in the end >>> d = LinkedDeque() >>> d.is_empty() True >>> d.remove_last() Traceback (most recent call last): ... IndexError: remove_first from empty list >>> d.add_first('A') # doctest: +ELLIPSIS >> d.remove_last() 'A' >>> d.is_empty() True .. py:class:: _DoublyLinkedBase A Private class (to be inherited) .. py:class:: _Node(link_p, element, link_n) .. py:method:: has_next_and_prev() .. py:attribute:: __slots__ :value: ('_data', '_next', '_prev') .. py:attribute:: _data .. py:attribute:: _next .. py:attribute:: _prev .. py:method:: __len__() .. py:method:: _delete(node) .. py:method:: _insert(predecessor, e, successor) .. py:method:: is_empty() .. py:attribute:: _header .. py:attribute:: _size :value: 0 .. py:attribute:: _trailer