void preNext(struct node *root, int *arr, int *index) { arr[(*index)++] = root->data; if (root->left != NULL) preNext(root->left, arr, index); if (root->right != NULL) preNext(root->right, arr, index); }
void c_Continuation::t_next() { INSTANCE_METHOD_INJECTION_BUILTIN(Continuation, Continuation::next); const_assert(!hhvm); preNext(); m_received.setNull(); nextImpl(fi); }
void c_Continuation::t_send(CVarRef v) { INSTANCE_METHOD_INJECTION_BUILTIN(Continuation, Continuation::send); const_assert(!hhvm); startedCheck(); preNext(); m_received.assignVal(v); nextImpl(fi); }
void c_Continuation::t_raise(CVarRef v) { INSTANCE_METHOD_INJECTION_BUILTIN(Continuation, Continuation::raise); const_assert(!hhvm); startedCheck(); preNext(); m_received.assignVal(v); m_should_throw = true; nextImpl(fi); }
void preorder(struct node *root, int *arr){ if (root == NULL || arr == NULL) return; else { int index = 0; preNext(root, arr, &index); } }
inline void c_Continuation::nextImpl(FI& fi) { const_assert(!hhvm); preNext(); try { if (m_isMethod) { MethodCallPackage mcp; mcp.isObj = hhvm || m_obj.get(); if (mcp.isObj) { mcp.obj = mcp.rootObj = m_obj.get(); } else { mcp.rootCls = m_called_class.get(); } mcp.extra = m_extra; if (!hhvm) { fi.setStaticClassName(m_called_class); } (m_callInfo->getMeth1Args())(mcp, 1, this); } else { if (hhvm) { MethodCallPackage mcp; mcp.isObj = false; mcp.obj = mcp.rootObj = NULL; mcp.extra = m_extra; (m_callInfo->getMeth1Args())(mcp, 1, this); } else { (m_callInfo->getFunc1Args())(m_extra, 1, this); } } } catch (Object e) { if (e.instanceof("exception")) { m_running = false; m_done = true; throw_exception(e); } else { throw; } } m_running = false; }
void BtreeNode::for_preIter(const std::function<void(const BtreeNode *)> &fn)const { for(const BtreeNode *x = preFirst(); x; x=preNext()) fn(x); }