def test_isCircularll(): ll = LinkedListFIFO() for i in range(10): ll.addNode(i) assert (isCircularll(ll) is False) lcirc = CircularLinkedListFIFO() for i in range(10): lcirc.addNode(i) assert (isCircularll(lcirc) is True) print("테스트 통과!")
def test_checkllPal(): ll = LinkedListFIFO() l1 = [1, 2, 3, 2, 1] for i in l1: ll.addNode(i) assert(checkllPal(ll) is True) ll.addNode(2) ll.addNode(3) assert(checkllPal(ll) is False) print("테스트 통과!")
def _createHashTable(self): for i in range(self.size): self.slots.append(LinkedListFIFO())
def partList(ll, n): more = LinkedListFIFO() less = LinkedListFIFO() node = ll.head while node: item = node.value if item < n: less.addNode(item) elif item > n: more.addNode(item) node = node.pointer less.addNode(n) nodemore = more.head while nodemore: less.addNode(nodemore.value) nodemore = nodemore.pointer return less
if item < n: less.addNode(item) elif item > n: more.addNode(item) node = node.pointer less.addNode(n) nodemore = more.head while nodemore: less.addNode(nodemore.value) nodemore = nodemore.pointer return less if __name__ == "__main__": ll = LinkedListFIFO() l = [6, 7, 3, 4, 9, 5, 1, 2, 8] for i in l: ll.addNode(i) print("분할 전:") ll._printList() print("분할 후:") newll = partList(ll, 6) newll._printList()