Struct hexodsp::wblockdsp::BlockChain
source · [−]pub struct BlockChain {
area_id: usize,
blocks: HashSet<(i64, i64)>,
sources: HashSet<(i64, i64)>,
sinks: HashSet<(i64, i64)>,
load: Vec<(Box<Block>, i64, i64)>,
}
Expand description
Represents a connected collection of blocks. Is created by BlockFun::retrieve_block_chain_at or BlockArea::chain_at.
After creating a BlockChain structure you can decide to clone the blocks from the BlockArea with BlockChain::clone_load or remove the blocks from the BlockArea and store them inside this BlockChain via BlockChain::remove_load.
The original positions of the loaded blocks is stored too. If you want to move the whole chain in the coordinate system to the upper left most corner, you can use BlockChain::normalize_load_pos.
Fields
area_id: usize
The area ID this BlockChain was created from.
blocks: HashSet<(i64, i64)>
Stores the positions of the blocks of the chain inside the BlockArea.
sources: HashSet<(i64, i64)>
Stores the positions of blocks that only have output ports.
sinks: HashSet<(i64, i64)>
Stores the positions of blocks that only have input ports.
load: Vec<(Box<Block>, i64, i64)>
This field stores loaded blocks from the BlockArea into this BlockChain for inserting or analyzing them.
Stores the blocks themself, with their position in the BlockArea, which can be normalized (moved to the upper left) with BlockChain::normalize_load_pos.
The blocks in this Vec are stored in sorted order.
They are stored in ascending order of their x
coordinate,
and for the same x
coordinate in
ascending order of their y
coordinate.
Implementations
sourceimpl BlockChain
impl BlockChain
pub fn move_by_offs(&mut self, xo: i64, yo: i64)
sourcepub fn normalize_load_pos(&mut self) -> (i64, i64)
pub fn normalize_load_pos(&mut self) -> (i64, i64)
Normalizes the position of all loaded blocks and returns the original top left most position of the chain.