Beispiel #1
0
class Stack:
    def __init__(self):
        self.stack = LinkedList()

    def push(self, obj):
        self.stack.add(obj)

    def pop(self):
        return self.stack.poll_last()

    def peak(self):
        return self.stack.get_last()

    def size(self):
        return self.stack.size()

    def isEmpty(self):
        return self.stack.is_empty()
Beispiel #2
0
class DeQueue:
    def __init__(self):
        self.queue = LinkedList()

    def enqueue_from_rear(self, obj):
        self.queue.add(obj)

    def enqueue_from_front(self, obj):
        self.queue.add_first(obj)

    def dequeue_from_rear(self):
        return self.queue.poll_last()

    def dequeue_from_front(self):
        return self.queue.poll_first()

    def size(self):
        return self.queue.size()

    def is_empty(self):
        return self.queue.is_empty()