The Visitor of Elemental Nodes
Represent an operation to be performed on the elements of an object structure without changing the classes in Move.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Visitor
ARCANUM SCHOOL: Divination // Analytics
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module arcane::visitor {
struct ElementNode has drop { value: u64 }
struct Visitor has drop {
sum: u64,
}
public fun new_visitor(): Visitor {
Visitor { sum: 0 }
}
public fun visit(visitor: &mut Visitor, node: &ElementNode) {
visitor.sum = visitor.sum + node.value;
}
}
Runic Tags:
#behavioral
#visitor
#move
#traversals