void getHelper(TreeNode *root, int k, int res, int count) { if (!root) { return; } getHelper(root->left, k, res, count); if (++count == k) { res = root->val; return; } getHelper(root->right, k, res, count); }
TR_RuntimeHelper TR::S390CallSnippet::getInterpretedDispatchHelper( TR::SymbolReference *methodSymRef, TR::DataType type) { TR::Compilation *comp = cg()->comp(); TR::MethodSymbol * methodSymbol = methodSymRef->getSymbol()->castToMethodSymbol(); bool isJitInduceOSRCall = false; if (methodSymbol->isHelper() && methodSymRef->isOSRInductionHelper()) { isJitInduceOSRCall = true; } if (methodSymRef->isUnresolved() || comp->compileRelocatableCode()) { TR_ASSERT(!isJitInduceOSRCall || !comp->compileRelocatableCode(), "calling jitInduceOSR is not supported yet under AOT\n"); if (methodSymbol->isSpecial()) return TR_S390interpreterUnresolvedSpecialGlue; else if (methodSymbol->isStatic()) return TR_S390interpreterUnresolvedStaticGlue; else return TR_S390interpreterUnresolvedDirectVirtualGlue; } else if (isJitInduceOSRCall) return (TR_RuntimeHelper) methodSymRef->getReferenceNumber(); else return getHelper(methodSymbol, type, cg()); }
// followup // kth smallest node in bst // o(n) int getKthNode(TreeNode *root, int k) { int res = 0, count = 0; getHelper(root, k, count, res); return res; }
/* readonly attribute double exposureCompensation; */ NS_IMETHODIMP nsCameraControl::GetExposureCompensation(double *aExposureCompensation) { return getHelper(this, CAMERA_PARAM_EXPOSURECOMPENSATION, aExposureCompensation); }
/* readonly attribute double focusDistanceOptimum; */ NS_IMETHODIMP nsCameraControl::GetFocusDistanceOptimum(double *aFocusDistanceOptimum) { return getHelper(this, CAMERA_PARAM_FOCUSDISTANCEOPTIMUM, aFocusDistanceOptimum); }
/* readonly attribute double focusDistanceFar; */ NS_IMETHODIMP nsCameraControl::GetFocusDistanceFar(double *aFocusDistanceFar) { return getHelper(this, CAMERA_PARAM_FOCUSDISTANCEFAR, aFocusDistanceFar); }
/* attribute jsval focusAreas; */ NS_IMETHODIMP nsCameraControl::GetFocusAreas(JSContext *cx, JS::Value *aFocusAreas) { return getHelper(this, CAMERA_PARAM_FOCUSAREAS, cx, aFocusAreas); }
/* readonly attribute double focalLength; */ NS_IMETHODIMP nsCameraControl::GetFocalLength(double *aFocalLength) { return getHelper(this, CAMERA_PARAM_FOCALLENGTH, aFocalLength); }
/* attribute double zoom; */ NS_IMETHODIMP nsCameraControl::GetZoom(double *aZoom) { return getHelper(this, CAMERA_PARAM_ZOOM, aZoom); }
/* attribute jsval meteringAreas; */ NS_IMETHODIMP nsCameraControl::GetMeteringAreas(JSContext *cx, JS::Value *aMeteringAreas) { return getHelper(this, CAMERA_PARAM_METERINGAREAS, cx, aMeteringAreas); }
/* attribute DOMString focusMode; */ NS_IMETHODIMP nsCameraControl::GetFocusMode(nsAString & aFocusMode) { return getHelper(this, CAMERA_PARAM_FOCUSMODE, aFocusMode); }
/* attribute DOMString flashMode; */ NS_IMETHODIMP nsCameraControl::GetFlashMode(nsAString & aFlashMode) { return getHelper(this, CAMERA_PARAM_FLASHMODE, aFlashMode); }
/* attribute DOMString sceneMode; */ NS_IMETHODIMP nsCameraControl::GetSceneMode(nsAString & aSceneMode) { return getHelper(this, CAMERA_PARAM_SCENEMODE, aSceneMode); }
/* attribute DOMString whiteBalanceMode; */ NS_IMETHODIMP nsCameraControl::GetWhiteBalanceMode(nsAString & aWhiteBalanceMode) { return getHelper(this, CAMERA_PARAM_WHITEBALANCE, aWhiteBalanceMode); }
/* attribute DOMString effect; */ NS_IMETHODIMP nsCameraControl::GetEffect(nsAString & aEffect) { return getHelper(this, CAMERA_PARAM_EFFECT, aEffect); }