zoukankan      html  css  js  c++  java
  • 检索树算法

    树结构例如以下所看到的:


    要求:需依照属性检索出当中一个树节点并返回值。

    思路:

            List<IntPtr> ptrList = new List<IntPtr>();
            IntPtr getEidtPtr(IntPtr fatherPtr)
            {
                if(fathrPtr 中包括目标子节点)
                        return editPtr;
                    else
                    {
                        if (假设节点存在下一级节点)
                        {
                            ptrList.Add(nextPtr);
                            return getEidtPtr(nextPtr);
                        }
                        else
                        {
                            ptrList.Remove(fatherPtr);
                            if (假设fatherPtr存在同级节点)
                            {
                                ptrList.Add(standPtr);
                                return getEidtPtr(standPtr);
                            }
                            else
                            {
                                if (ptrList.Count == 0)
                                    return IntPtr.Zero;
                                else
                                {
                                    IntPtr f = getUpPtr();
                                    return  getEidtPtr(f);
                                }
                            }
                        }
                    }
               
            }


            IntPtr getUpPtr()
            {
                IntPtr fatherPtr1 = ptrList[ptrList.Count - 1];
                ptrList.Remove(fatherPtr1);
                IntPtr stand =得到fatherPtr1的同级节点;
                if (stand != IntPtr.Zero)
                    return stand;
                else
                    return  getUpPtr();
            }
  • 相关阅读:
    欢迎加入强哥的 Android 开发交流群
    HashMap和ConcurrentHashMap的区别,HashMap的底层源码
    angular ngIf 导致不点击屏幕,就无法显示内容的问题
    angular date 过滤器不兼容 ios 造成 列表循环渲染错误的问题
    部署Node.js到阿里云服务器CentOs
    使用手淘VW适配方案后造成伪类使用content报错的解决办法
    Vue 加载 Sass Loader 报错的解决方案
    Typescript中private、public、protected修饰符的区别
    搭建Android开发环境 以及 ionic 编译安卓app步骤
    前端开发规范:3-CSS
  • 原文地址:https://www.cnblogs.com/jhcelue/p/7356047.html
Copyright © 2011-2022 走看看