tree_structures 0.0.5 copy "tree_structures: ^0.0.5" to clipboard
tree_structures: ^0.0.5 copied to clipboard

tree_structures is a Dart implentation of (currently only) a red-black self-balancing binary search tree with a possibility to output to Graphviz for previewing.

example/tree_structures_example.dart

import 'package:tree_structures/tree_structures.dart';

main() {
  var tree = RBTree<int, dynamic>();
  tree.insert(100, "data associated with 100");
  tree.insert(150, "data associated with 150");
  tree.remove(100);
  tree.insert(200, "data associated with 200");
  tree.insert(20, "data associated with 20");
  tree.insert(25, "data associated with 25");
  tree.insert(18, "data associated with 18");
  tree.insert(120, "data associated with 120");
  tree.insert(180, "data associated with 180");
  print(tree);
  tree.forEach((node) {
    print("${node.key}:${node.value}");
    return true; // continue
  });
  print(tree.output(OutputStyle.Graphviz));
  var sb = StringBuffer();
  tree.forEach((node) {
    if (sb.length > 0) {
      sb.write(",");
    }
    sb.write("${node.key}");
    return true;
  });
  print(sb.toString());
}
1
likes
130
pub points
24%
popularity

Publisher

verified publisherimagineusthere.com

tree_structures is a Dart implentation of (currently only) a red-black self-balancing binary search tree with a possibility to output to Graphviz for previewing.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on tree_structures