コード例 #1
0
def change_list2(n):
    n1 = Node(3)
    n2 = Node(4)
    n3 = Node(5)
    n4 = Node(6)
    n1.next = n2
    n2.next = n3
    n3.next = n4
    n.next = n1
コード例 #2
0
ファイル: test_node.py プロジェクト: VimanyuAgg/code-morsels
 def testListManipulationInCallable(self):
     h = Node(3)
     h2 = Node(4)
     h3 = Node(5)
     self.__addNode(h,h2)
     self.assertEqual(h.next, h2)
     self.__addNode(h.next,h3)
     self.assertEqual(h2.next, h3)
     h.next = h3
     self.assertEqual(h.next, h3)
コード例 #3
0
def intersection():
    n = Node(0)
    s = set()
    s.add(n)
    n1 = Node(0)

    if n in s:
        print("hi<-- gets printed")
    else:
        print("nay")

    if n1 in s:
        print("hi")
    else:
        print("nay <-- gets printed")
コード例 #4
0
def check2():
    h = Node(3)
    change_list2(h)
    print(h)
    print(h.next)
    print(h.next.next)
    print(h.next.next.next)
コード例 #5
0
def check1():
    n1 = Node(3)
    n2 = Node(4)
    n3 = Node(5)
    n4 = Node(6)
    n1.next = n2
    n2.next = n3
    n3.next = n4
    print(n1)
    print(n2)
    print(n3)
    print(n4)
    change_list(n1)
    print("****")
    print(n1)
    print(n2)
    print(n3)
    print(n4)
コード例 #6
0
def check3():
    n1 = Node(300)
    n1.next = Node(400)
    n1.next.next = Node(500)
    h = n1
    h.next = Node(10000)
    print(n1)
コード例 #7
0
ファイル: test_node.py プロジェクト: VimanyuAgg/code-morsels
 def testListManipulation(self):
     h = Node(3)
     h2 = Node(4)
     h3 = Node(5)
     h.next = h2
     h.next.next = h3
     self.assertEqual(h2.next, h3)
     h.next = h3
     self.assertEqual(h.next, h3)
コード例 #8
0
ファイル: test_node.py プロジェクト: VimanyuAgg/code-morsels
 def testNullNodeCreation(self):
     h = Node()
     print(h)
     self.assertEqual(h, None)
     self.assertEqual(h.val, None)
     self.assertEqual(h.next, None)
コード例 #9
0
ファイル: test_node.py プロジェクト: VimanyuAgg/code-morsels
 def testListCreation(self):
     h = Node(3)
     h2 = Node(4)
     h.next = h2
     self.assertEqual(h.val, 3)
     self.assertEqual(h.next, h2)
コード例 #10
0
ファイル: test_node.py プロジェクト: VimanyuAgg/code-morsels
 def testNonNodeAddition(self):
     h = Node(3)
     with self.assertRaises(TypeError):
         h.next = 5
コード例 #11
0
ファイル: test_node.py プロジェクト: VimanyuAgg/code-morsels
 def testNodeCreation(self):
     h = Node(3)
     # self.assertEqual(print(h), "Node(3)->None")
     self.assertEqual(h.val, 3)
     self.assertEqual(h.next, None)