May 2019
Intermediate to advanced
698 pages
17h 21m
English
As in the previous implementation, this tree builds on the numerical_id property of IoTDevice as keys, and the device object as value. In code, a node looks very similar to the previous example:
type Tree = Box<Node>;type KeyType = u64;type Data = (Option<IoTDevice>, Option<Tree>);#[derive(Clone, PartialEq, Debug)]enum NodeType { Leaf, Regular,}#[derive(Clone, PartialEq)]enum Direction { Left, Right(usize),}#[derive(Clone)]struct Node { devices: Vec<Option<IoTDevice>>, children: Vec<Option<Tree>>, left_child: Option<Tree>, pub node_type: NodeType,}
Instead of triples, this node type uses a synchronized index to find the children associated with a specified key-value pair. These pairs are also created ad hoc by evaluating the ...
Read now
Unlock full access