Exemple #1
0
class ListStack:
    def __init__(self):
        self._data = LinkedList()

    def push(self, value):
        self._data.insertAtHead(value)

    def pop(self):
        return self._data.pop_head()

    def is_empty(self):
        return (self._data.size() == 0)

    def peek(self):
        return self._data._head.get_value()
Exemple #2
0
class ListQueue:
    def __init__(self):
        self._data = LinkedList()

    def enqueue(self, value):
        self._data.insertAtTail(value)

    def dequeue(self):
        return self._data.pop_head()

    def is_empty(self):
        return (self._data.size() == 0)

    def size(self):
        self._data.size()
Exemple #3
0
class ListStack:

    def __init__(self):
        self._data = LinkedList()

    def push(self, value):
        self._data.insertAtHead(value)
        
    def pop(self):
        return self._data.pop_head()

    def is_empty(self):
        return (self._data.size() == 0)

    def peek(self):
    	return self._data._head.get_value()
Exemple #4
0
class ListQueue:

    def __init__(self):
        self._data = LinkedList()

    def enqueue(self, value):
        self._data.insertAtTail(value)

    def dequeue(self):
        return self._data.pop_head()

    def is_empty(self):
        return (self._data.size() == 0)

    def size(self):
        self._data.size()