Public Member Functions | |
| def | __init__ |
| Constructs a new empty RandomQueue. | |
| def | empty |
| Returns True if this RandomQueue is empty. | |
| def | push |
| Push a new element into the RandomQueue. | |
| def | pop |
| Pops a randomly selected element from the queue. | |
Public Attributes | |
| array | |
| The internal list to store objects. | |
This class is useful for implementing algorithms that gather elements, and need to process them randomly. Something along the lines of:
while not rqueue.empty(): #generates 3 new elements to process for i in range(3): rqueue.push(process(rqueue.pop()))
Definition at line 51 of file enhanced_grid.py.
| def enhanced_grid.RandomQueue.__init__ | ( | self | ) |
| def enhanced_grid.RandomQueue.empty | ( | self | ) |
| def enhanced_grid.RandomQueue.pop | ( | self | ) |
Pops a randomly selected element from the queue.
All elements can be selected equiprobably
Definition at line 68 of file enhanced_grid.py.
| def enhanced_grid.RandomQueue.push | ( | self, | ||
| x | ||||
| ) |
1.5.8