org.mozilla.javascript.NativeArray.heapify_extended()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 JavaScript  
字(1.5k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.mozilla.javascript.NativeArray.heapify_extended()方法的一些代码示例,展示了NativeArray.heapify_extended()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NativeArray.heapify_extended()方法的具体详情如下:
包路径:org.mozilla.javascript.NativeArray
类名称:NativeArray
方法名:heapify_extended

NativeArray.heapify_extended介绍

暂无

代码示例

代码示例来源:origin: rhino/js

/** Version of heapsort that call getElem/setElem on target to query/assign
 * array elements instead of Java array access
 */
  private static void heapsort_extended(Context cx, Scriptable scope,
                     Scriptable target, long length,
                     Object cmp, Object[] cmpBuf)
  {
    if (length <= 1) Kit.codeBug();

    // Build heap
    for (long i = length / 2; i != 0;) {
      --i;
      Object pivot = getElem(cx, target, i);
      heapify_extended(cx, scope, pivot, target, i, length, cmp, cmpBuf);
    }

    // Sort heap
    for (long i = length; i != 1;) {
      --i;
      Object pivot = getElem(cx, target, i);
      setElem(cx, target, i, getElem(cx, target, 0));
      heapify_extended(cx, scope, pivot, target, 0, i, cmp, cmpBuf);
    }
  }

代码示例来源:origin: com.sun.phobos/phobos-rhino

/** Version of heapsort that call getElem/setElem on target to query/assign
 * array elements instead of Java array access
 */
  private static void heapsort_extended(Context cx, Scriptable scope,
                     Scriptable target, long length,
                     Object cmp, Object[] cmpBuf)
  {
    if (length <= 1) Kit.codeBug();

    // Build heap
    for (long i = length / 2; i != 0;) {
      --i;
      Object pivot = getElem(cx, target, i);
      heapify_extended(cx, scope, pivot, target, i, length, cmp, cmpBuf);
    }

    // Sort heap
    for (long i = length; i != 1;) {
      --i;
      Object pivot = getElem(cx, target, i);
      setElem(cx, target, i, getElem(cx, target, 0));
      heapify_extended(cx, scope, pivot, target, 0, i, cmp, cmpBuf);
    }
  }

相关文章

微信公众号