zoukankan      html  css  js  c++  java
  • 一个不错的多叉树, stl风格

    tree<std::string> tr9;
    tree<std::string>::pre_order_iterator iter1;
    tr9.set_head("hi");
    tr9.insert_after(tr9.begin(), "a");
    tr9.insert_after(tr9.begin(), "b");
    tr9.append_child(tr9.begin(), "0");
    tr9.append_child(tr9.begin().begin(), "0.1");
    tr9.append_child(tr9.begin().begin(), "0.0");

    iter1 = tr9.begin();
    int num1 = iter1.number_of_children();
    if (num1 > 0) {
    iter1 = tr9.child(iter1, num1 - 1);
    if (iter1 == NULL)
    XTRACE_RAW(COLOR_BLACK, "null iter? ");
    else
    tr9.insert_after(iter1, "2");
    } else {
    tr9.append_child(tr9.begin(), "1");
    }
    print_tree(tr9, tr9.begin(), tr9.end());
    int depth1 = tr9.depth(tr9.begin());
    int depth2 = tr9.depth(tr9.begin().begin());
    int size1 = tr9.size();
    int size2 = tr9.size(tr9.begin());

    tree<std::string> tr;
    tree<std::string>::pre_order_iterator html, body, h1, h3, bh1, mv1;

    print_tree(tr, tr.begin(), tr.end());

    html=tr.insert(tr.begin(), "html");
    tr.insert_after(html, "extra");
    body=tr.append_child(html, "body");
    h1 =tr.append_child(body, "h1");
    bh1 = tr.insert_after(h1, "after h1");
    auto aa = tr.parent(bh1);
    tr.append_child(aa, "some textaaa");
    tr.append_child(h1, "some text");
    tr.append_child(body, "more text");

    print_tree(tr, tr.begin(), tr.end());

    XTRACE_RAW(COLOR_BLACK, L"test finish ");

    url: http://tree.phi-sci.com/

  • 相关阅读:
    c# 键值数据保存XML文件
    c# 封装 Request操作类
    c# 获取客户端IP
    c#封装DBHelper类
    c# Cache 使用实例
    c#cookie读取写入操作
    c# Session写入读取操作
    ABAP-HTTP支持
    WDA-文档-基础篇/进阶篇/讨论篇
    UI5-文档-4.38-Accessibility
  • 原文地址:https://www.cnblogs.com/wjx0912/p/7475143.html
Copyright © 2011-2022 走看看