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);
} 
Example #2
0
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;
}
Example #4
0
/* readonly attribute double exposureCompensation; */
NS_IMETHODIMP
nsCameraControl::GetExposureCompensation(double *aExposureCompensation)
{
  return getHelper(this, CAMERA_PARAM_EXPOSURECOMPENSATION, aExposureCompensation);
}
Example #5
0
/* readonly attribute double focusDistanceOptimum; */
NS_IMETHODIMP
nsCameraControl::GetFocusDistanceOptimum(double *aFocusDistanceOptimum)
{
  return getHelper(this, CAMERA_PARAM_FOCUSDISTANCEOPTIMUM, aFocusDistanceOptimum);
}
Example #6
0
/* readonly attribute double focusDistanceFar; */
NS_IMETHODIMP
nsCameraControl::GetFocusDistanceFar(double *aFocusDistanceFar)
{
  return getHelper(this, CAMERA_PARAM_FOCUSDISTANCEFAR, aFocusDistanceFar);
}
Example #7
0
/* attribute jsval focusAreas; */
NS_IMETHODIMP
nsCameraControl::GetFocusAreas(JSContext *cx, JS::Value *aFocusAreas)
{
  return getHelper(this, CAMERA_PARAM_FOCUSAREAS, cx, aFocusAreas);
}
Example #8
0
/* readonly attribute double focalLength; */
NS_IMETHODIMP
nsCameraControl::GetFocalLength(double *aFocalLength)
{
  return getHelper(this, CAMERA_PARAM_FOCALLENGTH, aFocalLength);
}
Example #9
0
/* attribute double zoom; */
NS_IMETHODIMP
nsCameraControl::GetZoom(double *aZoom)
{
  return getHelper(this, CAMERA_PARAM_ZOOM, aZoom);
}
Example #10
0
/* attribute jsval meteringAreas; */
NS_IMETHODIMP
nsCameraControl::GetMeteringAreas(JSContext *cx, JS::Value *aMeteringAreas)
{
  return getHelper(this, CAMERA_PARAM_METERINGAREAS, cx, aMeteringAreas);
}
Example #11
0
/* attribute DOMString focusMode; */
NS_IMETHODIMP
nsCameraControl::GetFocusMode(nsAString & aFocusMode)
{
  return getHelper(this, CAMERA_PARAM_FOCUSMODE, aFocusMode);
}
Example #12
0
/* attribute DOMString flashMode; */
NS_IMETHODIMP
nsCameraControl::GetFlashMode(nsAString & aFlashMode)
{
  return getHelper(this, CAMERA_PARAM_FLASHMODE, aFlashMode);
}
Example #13
0
/* attribute DOMString sceneMode; */
NS_IMETHODIMP
nsCameraControl::GetSceneMode(nsAString & aSceneMode)
{
  return getHelper(this, CAMERA_PARAM_SCENEMODE, aSceneMode);
}
Example #14
0
/* attribute DOMString whiteBalanceMode; */
NS_IMETHODIMP
nsCameraControl::GetWhiteBalanceMode(nsAString & aWhiteBalanceMode)
{
  return getHelper(this, CAMERA_PARAM_WHITEBALANCE, aWhiteBalanceMode);
}
Example #15
0
/* attribute DOMString effect; */
NS_IMETHODIMP
nsCameraControl::GetEffect(nsAString & aEffect)
{
  return getHelper(this, CAMERA_PARAM_EFFECT, aEffect);
}