Public Member Functions | |
def | __init__ |
def | __str__ |
def | __iter__ |
Returns an iterator that iterates over columns. | |
def | cell_iter |
Returns an iterator that iterates over all cells in the grid. | |
def | window_index_iter |
Returns an iterator that iterates over a subgrid of this grid. | |
def | wrapped_window_index_iter |
Returns an iterator that iterates over a subgrid of this grid. | |
def | window_iter |
Returns an iterator that iterates over a subgrid of this grid. | |
def | wrapped_window_iter |
Returns an iterator that iterates over a subgrid of this grid. | |
def | square_index_iter |
Returns an iterator that iterates over all cells in the square surrounding the given point. | |
def | wrapped_square_index_iter |
Returns an iterator that iterates over all cells in the square surrounding the given point. | |
def | square_iter |
Returns an iterator that iterates over all cells in the square surrounding the given point. | |
def | wrapped_square_iter |
Returns an iterator that iterates over all cells in the square surrounding the given point. | |
def | index_iter |
Returns an iterator that iterates over the indeces of this grid as tuples. | |
Public Attributes | |
width | |
height |
Definition at line 465 of file enhanced_grid.py.
def enhanced_grid.Container2D.__init__ | ( | self, | ||
width, | ||||
height | ||||
) |
def enhanced_grid.Container2D.__iter__ | ( | self | ) |
Returns an iterator that iterates over columns.
This iterator is provided so that a Grid2D better emulates a list of lists, as in the following example:
for col in grid: for item in col: process(item)
Definition at line 496 of file enhanced_grid.py.
def enhanced_grid.Container2D.__str__ | ( | self | ) |
Definition at line 472 of file enhanced_grid.py.
def enhanced_grid.Container2D.cell_iter | ( | self | ) |
Returns an iterator that iterates over all cells in the grid.
This allows you to write:
for cell in cell_iter(grid): process(cell)
Reimplemented in enhanced_grid.Grid2D.
Definition at line 508 of file enhanced_grid.py.
def enhanced_grid.Container2D.index_iter | ( | self | ) |
Returns an iterator that iterates over the indeces of this grid as tuples.
If grid is a 2 by 2 grid, then:
for p in index_iter(grid): print p
0, 0 0, 1 1, 0 1, 1
for p in index_iter(grid): grid[p] = random()
Definition at line 645 of file enhanced_grid.py.
def enhanced_grid.Container2D.square_index_iter | ( | self, | ||
p, | ||||
n | ||||
) |
Returns an iterator that iterates over all cells in the square surrounding the given point.
The square is 2*n + 1 units.
Definition at line 590 of file enhanced_grid.py.
def enhanced_grid.Container2D.square_iter | ( | self, | ||
p, | ||||
n | ||||
) |
Returns an iterator that iterates over all cells in the square surrounding the given point.
The square is 2*n + 1 units.
Definition at line 610 of file enhanced_grid.py.
def enhanced_grid.Container2D.window_index_iter | ( | self, | ||
p0, | ||||
p1 | ||||
) |
Returns an iterator that iterates over a subgrid of this grid.
The iterator will iterate over all cells x, y in the grid such that
x0 <= x < x1 y0 <= y < y1
Definition at line 523 of file enhanced_grid.py.
def enhanced_grid.Container2D.window_iter | ( | self, | ||
p0, | ||||
p1 | ||||
) |
Returns an iterator that iterates over a subgrid of this grid.
The iterator will iterate over all cells x, y in the grid such that
x0 <= x < x1 y0 <= y < y1
Definition at line 558 of file enhanced_grid.py.
def enhanced_grid.Container2D.wrapped_square_index_iter | ( | self, | ||
p, | ||||
n | ||||
) |
Returns an iterator that iterates over all cells in the square surrounding the given point.
The square is 2*n + 1 units. The iterator wraps over the grid. For example, if x is one unit too high (it is outside the grid to the right), the iterator will return first cell in that row.
Definition at line 601 of file enhanced_grid.py.
def enhanced_grid.Container2D.wrapped_square_iter | ( | self, | ||
p, | ||||
n | ||||
) |
Returns an iterator that iterates over all cells in the square surrounding the given point.
The square is 2*n + 1 units. The iterator wraps over the grid. For example, if x is one unit too high (it is outside the grid to the right), the iterator will return first cell in that row.
Definition at line 621 of file enhanced_grid.py.
def enhanced_grid.Container2D.wrapped_window_index_iter | ( | self, | ||
p0, | ||||
p1 | ||||
) |
Returns an iterator that iterates over a subgrid of this grid.
The iterator will iterate over all cells x, y in the grid such that
x0 <= x < x1 y0 <= y < y1
The iterator wraps over the grid. For example, if x is one unit too high (it is outside the grid to the right), the iterator will return the index of the first cell in that row.
Definition at line 542 of file enhanced_grid.py.
def enhanced_grid.Container2D.wrapped_window_iter | ( | self, | ||
p0, | ||||
p1 | ||||
) |
Returns an iterator that iterates over a subgrid of this grid.
The iterator will iterate over all cells x, y in the grid such that
x0 <= x < x1 y0 <= y < y1
The iterator wraps over the grid. For example, if x is one unit too high (it is outside the grid to the right), the iterator will return first cell in that row.
Definition at line 578 of file enhanced_grid.py.
Definition at line 468 of file enhanced_grid.py.