Documentation ¶
Index ¶
- type DiffOption
- type ReactDiff
- func (r *ReactDiff) Clone() *ReactDiff
- func (r *ReactDiff) DiffTree(targetTree *ReactDiff, option DiffOption) bool
- func (r *ReactDiff) DisplayGraphvizTree()
- func (r *ReactDiff) GetNodeIndex(searchTarget interface{}) int
- func (r *ReactDiff) InsertNode(val string, nodeIndex int) bool
- func (r *ReactDiff) RemoveNode(val string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiffOption ¶
type DiffOption int
const ( INSERT_MARKUP DiffOption = 1 << iota MOVE_EXISTING DiffOption = 1 << iota REMOVE_NODE DiffOption = 1 << iota )
type ReactDiff ¶
type ReactDiff struct { //Major node structure NodeList []string //Node set target to store all node item in this tree //It help to determine if any element is exist in this tree or not NodeSet map[string]bool }
React Diff is a binary unsort tree to represent the concept of React Diff React Diff has optimize tree diff algorithm to optimize original tree diff O(n^3) -> O(n)
func NewReactDiffTree ¶
New a React Diff Tree with define size The binary tree with basic alignment with array 0-> 1, 2 1-> 3, 4 2-> 5, 6 ....
func (*ReactDiff) DiffTree ¶
func (r *ReactDiff) DiffTree(targetTree *ReactDiff, option DiffOption) bool
Diff Tree will diff with input target tree, if not identical will replace to new one Return true if two tree is identical, false will replace to new one with React Diff Algorithm
func (*ReactDiff) DisplayGraphvizTree ¶
func (r *ReactDiff) DisplayGraphvizTree()
Print out tree structure via Graphviz
func (*ReactDiff) GetNodeIndex ¶
Return node index via node value, return -1 if node is not exist
func (*ReactDiff) InsertNode ¶
Insert node into ReactDiff tree below to Node Index It will return the node index and success or not Note: If parent node not exist, will return false
func (*ReactDiff) RemoveNode ¶
Remove node via node value, return true if node exist and successful delete