Package horizons :: Package world :: Package buildability :: Module connectedareacache :: Class ConnectedAreaCache
[hide private]
[frames] | no frames]

Class ConnectedAreaCache

source code

Query whether (x1, y1) and (x2, y2) are connected.

This class aims to let one cheaply query the id of the area where (x, y) are. Getting that information for (x1, y1) and (x2, y2) shows that it is possible to get from one to the other entirely within the area if and only if they have the same area id.

The area id is an arbitrary integer that is returned for all coordinates in a connected area. It is only valid between updates of the cache (any addition/removal may change the area id). Thus the ids should never be used for anything other than (in)equality checks.

Instance Methods [hide private]
 
__init__(self) source code
 
_label_area(self, seed_coords) source code
 
_renumber_affected_areas(self, affected_areas) source code
 
add_area(self, coords_list)
Add a list of new coordinates to the area.
source code
 
remove_area(self, coords_list)
Remove a list of existing coordinates from the area.
source code
Class Variables [hide private]
  __moves = [(-1, 0), (0,-1), (0, 1), (1, 0)]