Esempio n. 1
0
class Stack:
    singlyLinkedList = None

    def __init__(self):
        self.singlyLinkedList = SinglyLinkedList()

    def push(self, value):
        self.singlyLinkedList.insertIndex(1, value)

    def pop(self):
        self.singlyLinkedList.deleteIndex(1)
Esempio n. 2
0
class Queue:
    singlyLinkedList = None

    def __init__(self):
        self.singlyLinkedList = SinglyLinkedList()

    def enqueue(self, value):
        self.singlyLinkedList.insertIndex(1, value)

    def dequeue(self):
        self.singlyLinkedList.deleteIndex(self.singlyLinkedList.size)

    def printQ(self):
        self.singlyLinkedList.printList()
        print()