Skip to main content

TailedLinkedList.add_front

Adds an item to the front of the TailedLinkedList

Usage

add_front(item:Any)

Parameters:
      item : element
            The new element will be added to the front of the Linked List.

Returns:
      TailedLinkedList
            Returns the same Linked List containing the newly added item.

Example

from jellybeans.structures import TailedLinkedListLL1 = TailedLinkedList()LL1.add_front(4).add_front(3).add_front(2).add_front(1)print(LL1) # 1 => 2 => 3 => 4LL2 = TailedLinkedList([5, 6, 7])LL2.add_front(109)print(LL2) # 109 => 5 => 6 => 7