TreeUtils Class

Module: BinaryUtils

TreeUtils used to compare Tree.

Can also be used to compare Object structure.

Item Index

Methods

Methods

compare

(
  • oldTree
  • newTree
  • diffs
  • pathOldTree
  • pathNewTree
)
Array static

Compare two trees and return list of changes.

oldTree is compared to newTree. The list of changes indicate wath needs to be changed in oldTree to become wqual to the newTree.

Elements inside Trees are compared using their UUID.

The array returned from this method contains objects in the format {status:, uuid: , from: , to: }

Parameters:

  • oldTree Tree

    Old version of Tree.

  • newTree Tree

    New version of Tree.

  • diffs Array

    Recursive parameter (optional).

  • pathOldTree Array

    Recursive parameter (optional).

  • pathNewTree Array

    Recursive parameter (optional).

Returns:

Array:

Array with diffs between oldTree and newTree.

print

(
  • tree
  • level
)

Print tree into console, recursively.

Trees are represented by a UUID a parent and a children array.

Parameters:

  • tree Tree

    Tree object to be printed.

  • level Number

    Recursive parameter, not required.

test

()

Unit test for tree comparison.

Prints information into the console.

Attributes

DIFF_ADDED

Number

Flag used to indicate ADDED diff.

DIFF_MOVED

Number

Flag used to indicate MOVED diff.

DIFF_REMOVED

Number

Flag used to indicate REMOVED diff.