Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: UTF-8 -*-
- __author__ = 'Julio Tentor <jtentor@fi.unju.edu.ar>'
- import numpy
- class Stack(object):
- def __init__(self, capacity = 10):
- self.__capacity = capacity
- self.__datos = numpy.empty(self.__capacity, numpy.object)
- self.__count = 0
- def Push(self, x):
- if self.__count >= self.__capacity :
- raise ValueError("ERROR La pila está llena...")
- self.__datos[self.__count] = x
- self.__count += 1
- def Pop(self):
- if self.Empty :
- raise ValueError("ERROR La pila está vacía...")
- self.__count -= 1
- return self.__datos[self.__count]
- def Peek(self):
- if self.Empty :
- raise ValueError("ERROR La pila está vacía...")
- return self.__datos[self.__count - 1]
- def Top(self):
- return self.Peek()
- @property
- def Empty(self):
- return self.__count == 0
- @property
- def Count(self):
- return self.__count
- if __name__ == "__main__":
- pass
Add Comment
Please, Sign In to add comment