enhanced_grid.Container2D Class Reference

Class that implements __str__ and __iter__. More...

Inheritance diagram for enhanced_grid.Container2D:

enhanced_grid.Container enhanced_grid.Grid2D enhanced_grid.GridSliceXY enhanced_grid.GridSliceXZ enhanced_grid.GridSliceYZ enhanced_grid.GridWindow2D quadtree.Quadtree enhanced_grid.ListGrid2D

List of all members.

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


Detailed Description

Class that implements __str__ and __iter__.

Definition at line 465 of file enhanced_grid.py.


Member Function Documentation

def enhanced_grid.Container2D.__init__ (   self,
  width,
  height 
)

Reimplemented in enhanced_grid.Grid2D.

Definition at line 466 of file enhanced_grid.py.

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)
Use of this iterator is discouraged - it is slow

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
will produce
 0, 0
 0, 1
 1, 0
 1, 1
This iterator is useful for assigning elements of grids:
 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.


Member Data Documentation

Reimplemented in quadtree.Quadtree.

Definition at line 469 of file enhanced_grid.py.

Definition at line 468 of file enhanced_grid.py.


The documentation for this class was generated from the following file:

Generated on Sun May 24 21:48:21 2009 by  doxygen 1.5.8