libutilitaspy.data_structures.stacks

This module implements basic stacks. See http://en.wikipedia.org/wiki/Stack_(data_structure)

exception libutilitaspy.data_structures.stacks.EmptyStack[source]

This exception is used to indicate that a stack is empty when attempting to pop an item.

class libutilitaspy.data_structures.stacks.Stack(elements=[])[source]

This class implements basic stacks, supporting non-popping iteration over its items.

push(item)[source]

Pushes item to the top of the stack.

pop()[source]

Pops and returns the top of the stack. :returns: The top item in the stack. :raises EmptyStack: if the stack is empty.

top()[source]

Returns the top of the stack without poping it. :returns: The top item in the stack. :raises EmptyStack: if the stack is empty.

isempty()[source]
Returns:True if the stack is empty, False otherwise.
next()[source]

Obtains the next item in the stack, without removing it. :raises: StopIteration if the iterator reaches the bottom of the stack.

Previous topic

libutilitaspy.data_structures.graphs

Next topic

libutilitaspy.data_structures.tries

This Page