The Composite Magic Node
Compose resources into tree structures to represent part-whole hierarchies in Move.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Composite
ARCANUM SCHOOL: Conjuration // Worldbuilding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module arcane::composite {
use std::vector;
struct Node has store, drop {
value: u64,
children: vector<Node>,
}
public fun create_leaf(value: u64): Node {
Node { value, children: vector::empty() }
}
public fun add_child(parent: &mut Node, child: Node) {
vector::push_back(&mut parent.children, child);
}
}
Runic Tags:
#structural
#composite
#move
#hierarchy