/** Find a chain of HexBlocks from $large until one of the same size as $small and adjacent to it */
Find a chain of HexBlocks from $large until one of the same size as $small and adjacent to it
Find a chain of HexBlocks from $large until one of the same size as $small and adjacent to it
fn find_chains(small: &HexBlock, large: &HexBlock) -> Vec<HexChain> {
		let mut parent_chains = vec![ HexChain(vec![large.clone()]) ];
		for gridsize in (small.size .. large.size).rev() {
			let mut next_parent_chains = Vec::with_capacity(parent_chains.len());
			for chain in parent_chains {
				let chain_head = chain.last().unwrap();
				for child in chain_head.ring_children().unwrap().iter() {
					// gridsize is the same as the size of the children
					if dist(small, child) <= grid_distance(gridsize) {
						let mut new_chain = chain.clone();
						new_chain.push(child.clone());
						next_parent_chains.push(new_chain);
					}
				}
			}
			parent_chains = next_parent_chains;
		}
		for chain in &mut parent_chains {
			chain.remove(0);
		}
		parent_chains
	}
fn find_chains ( small : & HexBlock , large : & HexBlock ) -> Vec < HexChain > { let mut parent_chains = vec ! [ HexChain ( vec [ large clone ( ) ] ) ] ; for gridsize in ( small . size .. large . size ) . rev ( ) { let mut next_parent_chains = Vec :: with_capacity ( parent_chains . len ( ) ) ; for chain in parent_chains { let chain_head = chain . last ( ) . unwrap ( ) ; for child in chain_head . ring_children ( ) . unwrap ( ) . iter ( ) { // gridsize is the same as the size of the children if dist ( small , child ) <= grid_distance ( gridsize ) { let mut new_chain = chain . clone ( ) ; new_chain . push ( child . clone ( ) ) ; next_parent_chains . push ( new_chain ) ; } } } parent_chains = next_parent_chains ; } for chain in & mut parent_chains { chain . remove ( 0 ) ; } parent_chains }
Find a chain of HexBlocks from $large until one of the same size as $small and adjacent to it
Find a chain of HexBlocks from $large until one of the same size as $small and adjacent to it
small
&HexBlock
large
&HexBlock