gecode FunctionBranch 源码分析

  从名字上看,这个类的核心就在于function, 那么看代码:

    /// Function to call
    SharedData<std::function<void(Space& home)>> f;
    /// Call function just once
    bool done;

  的确是定义了一个function,然后一个状态,猜测是调用了function之后会设置为true,往下看代码:

  ExecStatus
  FunctionBranch::commit(Space& home, const Choice&, unsigned int) {
    done = true;
    GECODE_VALID_FUNCTION(f());
    f()(home);
    return home.failed() ? ES_FAILED : ES_OK;
  }

  在commit中调用了function,然后将状态设置为true,标识这个状态已经被调用。至于何时进行commit,在后面的文章中再进行分析。

posted @ 2017-08-30 22:14  crax  阅读(242)  评论(0编辑  收藏  举报