zoukankan      html  css  js  c++  java
  • 编程常见处理逻辑

    • remove 函数的返回值一般为 bool 类型,用以判断是否成功;

    • 如果要求序列有序,插入操作之前首先进行的 search 操作,寻找合适的位置,如果查找得到,则无需再次插入,如果返回为空,则插入在指定的位置;

    1. 含有父指针的二叉树结点

    含有父指针的二叉树结点,一般会定义这样的一个宏(获取从父节点指向自己的指针):

    #define FromParentTo(x) (IsRoot(x) ? _root : (IsLChild(x) ? (x).parent->lChild : (x).parent->rChild))
                    #define IsRoot(x) (x).parent == NULL
                    #define IsLChild(x) (!IsRoot(x) && (x).parent->lChild == x)

    2. 成员函数的相互调用

    typedef int Rank;
    
    template <typename T>
    class Vector{
    
    protected:
        int _size; int _capacity; T* _elem;
    
    public:
        Rank insert(Rank r, const T& e);
        Rank insert(const T& e) { insert(_size, e); }
    }
  • 相关阅读:
    Git常用命令
    maven profile动态选择配置文件
    Nodejs的偏函数
    用CountDownLatch来同步java的多线程
    NodeJS的Promise的用法
    alluxio常用命令
    常见小代码
    Mongodb
    Mysql_常用语法
    PostgreSQL
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9423717.html
Copyright © 2011-2022 走看看