pub struct Partitioning {
pub map: MapName,
neighbourhoods: BTreeMap<NeighbourhoodID, NeighbourhoodInfo>,
single_blocks: Vec<Block>,
neighbourhood_id_counter: usize,
block_to_neighbourhood: BTreeMap<BlockID, NeighbourhoodID>,
pub broken: bool,
pub custom_boundaries: BTreeMap<NeighbourhoodID, CustomBoundary>,
}
Fields§
§map: MapName
§neighbourhoods: BTreeMap<NeighbourhoodID, NeighbourhoodInfo>
§single_blocks: Vec<Block>
§neighbourhood_id_counter: usize
§block_to_neighbourhood: BTreeMap<BlockID, NeighbourhoodID>
§broken: bool
§custom_boundaries: BTreeMap<NeighbourhoodID, CustomBoundary>
Implementations§
Source§impl Partitioning
impl Partitioning
Sourcepub fn empty() -> Partitioning
pub fn empty() -> Partitioning
Only valid before the LTN tool has been activated this session
pub fn is_empty(&self) -> bool
pub fn seed_using_heuristics(map: &Map, timer: &mut Timer<'_>) -> Partitioning
Sourcepub fn transfer_blocks(
&mut self,
map: &Map,
add_all: Vec<BlockID>,
new_owner: NeighbourhoodID,
) -> Result<Option<NeighbourhoodID>>
pub fn transfer_blocks( &mut self, map: &Map, add_all: Vec<BlockID>, new_owner: NeighbourhoodID, ) -> Result<Option<NeighbourhoodID>>
Add all specified blocks to new_owner. Ok(None)
is success. Ok(Some(x))
is also
success, but means the old neighbourhood of SOME block in add_all
is now gone and
replaced with something new. (This call shouldn’t be used to remove multiple blocks at
once, since interpreting the result is confusing!)
Sourcepub fn remove_block_from_neighbourhood(
&mut self,
map: &Map,
id: BlockID,
) -> Result<Option<NeighbourhoodID>>
pub fn remove_block_from_neighbourhood( &mut self, map: &Map, id: BlockID, ) -> Result<Option<NeighbourhoodID>>
Needs to find an existing neighbourhood to take the block, or make a new one
Source§impl Partitioning
impl Partitioning
pub fn neighbourhood_block(&self, id: NeighbourhoodID) -> &Block
pub fn neighbourhood_area_km2(&self, id: NeighbourhoodID) -> String
pub fn get_info(&self, id: NeighbourhoodID) -> &NeighbourhoodInfo
pub fn override_neighbourhood_boundary_polygon( &mut self, id: NeighbourhoodID, polygon: Polygon, )
pub fn add_custom_boundary(&mut self, custom: CustomBoundary) -> NeighbourhoodID
pub fn all_neighbourhoods( &self, ) -> &BTreeMap<NeighbourhoodID, NeighbourhoodInfo>
fn neighbourhood_containing( &self, find_block: BlockID, ) -> Option<NeighbourhoodID>
pub fn all_single_blocks(&self) -> Vec<(BlockID, &Block)>
pub fn all_block_ids(&self) -> Vec<BlockID>
pub fn get_block(&self, id: BlockID) -> &Block
pub fn block_to_neighbourhood(&self, id: BlockID) -> NeighbourhoodID
pub fn neighbourhood_to_blocks(&self, id: NeighbourhoodID) -> BTreeSet<BlockID>
pub fn some_block_in_neighbourhood(&self, id: NeighbourhoodID) -> BlockID
Sourcepub fn calculate_frontier(&self, perim: &Perimeter) -> BTreeSet<BlockID>
pub fn calculate_frontier(&self, perim: &Perimeter) -> BTreeSet<BlockID>
Blocks on the “frontier” are adjacent to the perimeter, either just inside or outside.
fn adjacent_blocks(&self, id: BlockID) -> BTreeSet<BlockID>
fn make_merged_blocks( &self, map: &Map, input: BTreeSet<BlockID>, ) -> Result<Vec<Block>>
Sourcepub fn find_intermediate_blocks(
&self,
new_owner: NeighbourhoodID,
target_block: BlockID,
) -> Vec<BlockID>
pub fn find_intermediate_blocks( &self, new_owner: NeighbourhoodID, target_block: BlockID, ) -> Vec<BlockID>
We want to add target_block to new_owner, but we can’t. Find the blocks we may need to add first.
Trait Implementations§
Source§impl Clone for Partitioning
impl Clone for Partitioning
Source§fn clone(&self) -> Partitioning
fn clone(&self) -> Partitioning
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'de> Deserialize<'de> for Partitioning
impl<'de> Deserialize<'de> for Partitioning
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Partitioning
impl RefUnwindSafe for Partitioning
impl Send for Partitioning
impl Sync for Partitioning
impl Unpin for Partitioning
impl UnwindSafe for Partitioning
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.