Exemplo n.º 1
0
 def __init__(self, list):
     previous = None
     for data in list:
         node = Node()
         node.number = data
         if previous != None:
             previous.nextPointer = node
         previous = node
         if self.head == None:
             self.head = node
Exemplo n.º 2
0
def reverse(node):
    if(node == None):
        print("Called reverse on None")
        print("reverse is returning from being called on None")
        return None
    else:
        print("Called reverse on " +str(node.number))
        reverseOfRemainder = reverse(node.nextPointer)
        if node.nextPointer == None:
            print("reverse returned from being called on None") 
        else:
            print("reverse returned from being called on "+ str(node.nextPointer.number))
        newAppend = Node()
        newAppend.number = node.number
        newAppend.nextPointer = None
        reverseList = append(reverseOfRemainder,newAppend)
        print("reverse is returning from being called on "+ str(node.number))
        printList(reverseList)
        return reverseList
Exemplo n.º 3
0
	def test_node_numberStoresData(self):
		node = Node()
		expected = "expected result"
		node.number = "expected result"
		self.assertEquals(expected, node.number, "Setting a Node's data should succeed")
Exemplo n.º 4
0
	def test_removeNext_nextIsNull_succeeds(self):
		node = Node()
		node.nextPointer = None
		node.removeNext()