Пример #1
0
 def setUp(self):
     self._doubly_linkedList = DoublyLinkedList()
     self._doubly_linkedList.append(1)
     self._doubly_linkedList.append(2)
     self._doubly_linkedList.append(3)
     self._doubly_linkedList.append(4)
     #create a second linkedlist with 5, 6, 7
     self._secondList = DoublyLinkedList()
     self._secondList.append(5)
     self._secondList.append(6)
     self._secondList.append(7)
Пример #2
0
 def setUp(self):
     #build [2, 1, 1, 1]
     self._doubly_linkedList = DoublyLinkedList()
     self._doubly_linkedList.append(2)
     element_to_append = 1
     self._doubly_linkedList.extend(
         [element_to_append, element_to_append, element_to_append])
Пример #3
0
 def setUp(self):
     #build [1, 1, 1, 2]
     self._doubly_linkedList = DoublyLinkedList()
     element_to_append = 1
     self._doubly_linkedList.extend(
         [element_to_append, element_to_append, element_to_append])
     tail_element = 2
     self._doubly_linkedList.append(tail_element)
Пример #4
0
 def setUp(self):
     self._linked_list = DoublyLinkedList()
     self._shadow_list = []
     for i in range(10):
         random_element = randint(0, 1000)
         self._linked_list.append(random_element)
         self._shadow_list.append(
             random_element)  #will keep track of count and index
Пример #5
0
 def setUp(self):
     self._doubly_linkedList = DoublyLinkedList()
     self._doubly_linkedList.append(1)
     self._doubly_linkedList.append(2)
     self._doubly_linkedList.append(3)
     self._doubly_linkedList.append(4)
Пример #6
0
 def setUp(self):
     self._doubly_linkedList = DoublyLinkedList()
     self._extend_elements = [1, 2, 3, 4]
     self._doubly_linkedList.extend(self._extend_elements)
Пример #7
0
 def setUp(self):
     self._doubly_linkedList = DoublyLinkedList()
Пример #8
0
 def setUp(self):
     self._doubly_linkedList = DoublyLinkedList()
     element_to_append = 1
     self._doubly_linkedList.append(element_to_append)
     self._doubly_linkedList.append(element_to_append)
Пример #9
0
    #length of the list
    print('Length of the list is %s' % len(double_link_list))


def print_reverse_list(double_link_list):
    elements_in_list = []
    #iterate over the list
    for element in reversed(double_link_list):
        elements_in_list.append(element)
    print('Reversed List is now %s' % elements_in_list)
    #length of the list
    print('Length of the list is %s' % len(double_link_list))


if __name__ == '__main__':
    double_link_list = DoublyLinkedList()

    #add one element
    print('Adding element 1 to list')
    double_link_list.append(1)

    #we add the following list (iterable) of elements
    print('Adding elements 2 ,3 , 4, 5, 6, 7, 8, 9, 10')
    elements = [2, 3, 4, 5, 6, 7, 8, 9, 10]
    double_link_list.extend(elements)

    #head
    print('Head of list is: %s' % str(double_link_list.head))

    #tail
    print('Tail of list is: %s' % str(double_link_list.tail))