Note that this method will be linear (not constant) time in this
implementation!  Better not to use it.
551441
public double getPriority(Object key) {
    for (int i = 0; i < elements.size(); i++) {
      if (elements.get(i).equals(key)) {
        return priorities[i];
      }
    }
    throw new NoSuchElementException();
  }
1083324
def _to_linear(M, N, L, q):
    ""
    (x, y, u, k) = q
    return 2 * L * N * x + 2 * L * y + L * u + k
309285
private Object doOp(Op op) throws TimeoutException {
        try {
            if (op.txn != null)
                op.txn.add(op);
            Object result = runOp(op);
            if (result == PENDING)
                return op.getResult(timeout, TimeUnit.MILLISECONDS);
            else if (result == null && op.isCancelled())
                throw new CancellationException();
            else
                return result;
        } catch (java.util.concurrent.TimeoutException e) {
            throw new TimeoutException(e);
        } catch (InterruptedException e) {
            return null;
        } catch (ExecutionException e) {
            Throwable ex = e.getCause();
            if (ex instanceof TimeoutException)
                throw (TimeoutException) ex;
            Throwables.propagateIfPossible(ex);
            throw Throwables.propagate(ex);
        }
    }
505121
function(T, C, n, k) {
        var i;
        for (i = 0; i < k; i++) { C[i] = 0; }
        for (i = 0; i < n; i++) { C[T[i]]++; }
    }
1231370
def linear_interpolate_by_datetime(datetime_axis, y_axis, datetime_new_axis,
                                   enable_warning=True):
    
    numeric_datetime_axis = [
        totimestamp(a_datetime) for a_datetime in datetime_axis
    ]

    numeric_datetime_new_axis = [
        totimestamp(a_datetime) for a_datetime in datetime_new_axis
    ]

    return linear_interpolate(
        numeric_datetime_axis, y_axis, numeric_datetime_new_axis,
        enable_warning=enable_warning)
437930
private static boolean needPlural(final int n)
    {
        int tmp = 0;
        int an = Math.abs(n);

        while (an > 0)
        {
            tmp = an % 10;

            if (tmp > 1)
            {
                return true;
            }

            an /= 10;
        }

        return false;
    }
166824
def rigid_linear_interpolate_by_datetime(datetime_axis, y_axis, datetime_new_axis):
    
    numeric_datetime_axis = [
        totimestamp(a_datetime) for a_datetime in datetime_axis
    ]

    numeric_datetime_new_axis = [
        totimestamp(a_datetime) for a_datetime in datetime_new_axis
    ]

    return rigid_linear_interpolate(
        numeric_datetime_axis, y_axis, numeric_datetime_new_axis)
478510
final void normalize() {
        if (intLen == 0) {
            offset = 0;
            return;
        }

        int index = offset;
        if (value[index] != 0)
            return;

        int indexBound = index+intLen;
        do {
            index++;
        } while(index < indexBound && value[index] == 0);

        int numZeros = index - offset;
        intLen -= numZeros;
        offset = (intLen == 0 ?  0 : offset+numZeros);
    }
814837
private static int linearSearch(int[] histogramLevels, int value) {
		for (int i = 0; i < histogramLevels.length; i++) {
			if (value < histogramLevels[i]) {
				return i;
			}
		}
		return histogramLevels.length; //
	}
661477
@Override
    public final <T extends TimePoint<? super U, T>> T subtractFrom(T time) {

        return this.add(time, this, true);

    }
280629
@Override
  public final void sample()
  {
    long count = _count.getAndSet(0);
    long time = _time.getAndSet(0);

    if (count == 0)
      _value = 0;
    else
      _value = time / (double) count;
  }
966680
private void validate() {
        if (isDense() && isPattern())
            throw new IllegalArgumentException(
                    "Matrix cannot be dense with pattern storage");
        if (isReal() && isHermitian())
            throw new IllegalArgumentException(
                    "Data cannot be real with hermitian symmetry");
        if (!isComplex() && isHermitian())
            throw new IllegalArgumentException(
                    "Data must be complex with hermitian symmetry");
        if (isPattern() && isSkewSymmetric())
            throw new IllegalArgumentException(
                    "Storage cannot be pattern and skew symmetrical");
    }
919029
private Node tryMinimizeIf(Node n) {

    Node parent = n.getParent();

    Node originalCond = n.getFirstChild();

    /* If the condition is a literal, we'll let other
     * optimizations try to remove useless code.
     */
    if (NodeUtil.isLiteralValue(originalCond, true)) {
      return n;
    }

    Node thenBranch = originalCond.getNext();
    Node elseBranch = thenBranch.getNext();

    MinimizedCondition minCond = MinimizedCondition.fromConditionNode(originalCond);

    // Compute two minimized representations. The first representation counts
    // a leading NOT node, and the second ignores a leading NOT node.
    // If we can fold the if statement into a HOOK or boolean operation,
    // then the NOT node does not matter, and we prefer the second condition.
    // If we cannot fold the if statement, then we prefer the first condition.
    MeasuredNode unnegatedCond = minCond.getMinimized(MinimizationStyle.PREFER_UNNEGATED);
    MeasuredNode shortCond = minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT);

    if (elseBranch == null) {
      if (isFoldableExpressBlock(thenBranch)) {
        Node expr = getBlockExpression(thenBranch);
        if (!late && isPropertyAssignmentInExpression(expr)) {
          // Keep opportunities for CollapseProperties such as
          // a.longIdentifier || a.longIdentifier = ... -> var a = ...;
          // until CollapseProperties has been run.
          replaceNode(originalCond, unnegatedCond);
          return n;
        }

        if (shortCond.isNot()) {
          // if(!x)bar(); -> x||bar();
          Node replacementCond = replaceNode(originalCond, shortCond.withoutNot()).detach();
          Node or = IR.or(
              replacementCond,
              expr.removeFirstChild()).srcref(n);
          Node newExpr = NodeUtil.newExpr(or);
          parent.replaceChild(n, newExpr);
          reportChangeToEnclosingScope(parent);

          return newExpr;
        }
        // True, but removed for performance reasons.
        // Preconditions.checkState(shortCond.isEquivalentTo(unnegatedCond));

        // if(x)foo(); -> x&&foo();
        if (shortCond.isLowerPrecedenceThan(AND_PRECEDENCE)
            && isLowerPrecedence(expr.getFirstChild(), AND_PRECEDENCE)) {
          // One additional set of parentheses is worth the change even if
          // there is no immediate code size win. However, two extra pair of
          // {}, we would have to think twice. (unless we know for sure the
          // we can further optimize its parent.
          replaceNode(originalCond, shortCond);
          return n;
        }

        Node replacementCond = replaceNode(originalCond, shortCond).detach();
        Node and = IR.and(replacementCond, expr.removeFirstChild()).srcref(n);
        Node newExpr = NodeUtil.newExpr(and);
        parent.replaceChild(n, newExpr);
        reportChangeToEnclosingScope(parent);

        return newExpr;
      } else {

        // Try to combine two IF-ELSE
        if (NodeUtil.isStatementBlock(thenBranch) && thenBranch.hasOneChild()) {
          Node innerIf = thenBranch.getFirstChild();

          if (innerIf.isIf()) {
            Node innerCond = innerIf.getFirstChild();
            Node innerThenBranch = innerCond.getNext();
            Node innerElseBranch = innerThenBranch.getNext();

            if (innerElseBranch == null
                 && !(unnegatedCond.isLowerPrecedenceThan(AND_PRECEDENCE)
                   && isLowerPrecedence(innerCond, AND_PRECEDENCE))) {
              Node replacementCond = replaceNode(originalCond, unnegatedCond).detach();
              n.detachChildren();
              n.addChildToBack(
                  IR.and(
                      replacementCond,
                      innerCond.detach())
                      .srcref(originalCond));
              n.addChildToBack(innerThenBranch.detach());
              reportChangeToEnclosingScope(n);
              // Not worth trying to fold the current IF-ELSE into && because
              // the inner IF-ELSE wasn't able to be folded into && anyways.
              return n;
            }
          }
        }
      }
      replaceNode(originalCond, unnegatedCond);
      return n;
    }

    /* TODO(dcc) This modifies the siblings of n, which is undesirable for a
     * peephole optimization. This should probably get moved to another pass.
     */
    tryRemoveRepeatedStatements(n);

    // if(!x)foo();else bar(); -> if(x)bar();else foo();
    // An additional set of curly braces isn't worth it.
    if (shortCond.isNot() && !consumesDanglingElse(elseBranch)) {
      replaceNode(originalCond, shortCond.withoutNot());
      n.removeChild(thenBranch);
      n.addChildToBack(thenBranch);
      reportChangeToEnclosingScope(n);
      return n;
    }

    // if(x)return 1;else return 2; -> return x?1:2;
    if (isReturnExpressBlock(thenBranch) && isReturnExpressBlock(elseBranch)) {
      Node thenExpr = getBlockReturnExpression(thenBranch);
      Node elseExpr = getBlockReturnExpression(elseBranch);

      Node replacementCond = replaceNode(originalCond, shortCond).detach();
      thenExpr.detach();
      elseExpr.detach();

      // note - we ignore any cases with "return;", technically this
      // can be converted to "return undefined;" or some variant, but
      // that does not help code size.
      Node returnNode = IR.returnNode(
                            IR.hook(replacementCond, thenExpr, elseExpr)
                                .srcref(n));
      parent.replaceChild(n, returnNode);
      reportChangeToEnclosingScope(returnNode);
      return returnNode;
    }

    boolean thenBranchIsExpressionBlock = isFoldableExpressBlock(thenBranch);
    boolean elseBranchIsExpressionBlock = isFoldableExpressBlock(elseBranch);

    if (thenBranchIsExpressionBlock && elseBranchIsExpressionBlock) {
      Node thenOp = getBlockExpression(thenBranch).getFirstChild();
      Node elseOp = getBlockExpression(elseBranch).getFirstChild();
      if (thenOp.getToken() == elseOp.getToken()) {
        // if(x)a=1;else a=2; -> a=x?1:2;
        if (NodeUtil.isAssignmentOp(thenOp)) {
          Node lhs = thenOp.getFirstChild();
          if (areNodesEqualForInlining(lhs, elseOp.getFirstChild())
              // if LHS has side effects, don't proceed [since the optimization
              // evaluates LHS before cond]
              // NOTE - there are some circumstances where we can
              // proceed even if there are side effects...
              && !mayEffectMutableState(lhs)
              && (!mayHaveSideEffects(originalCond)
                  || (thenOp.isAssign() && thenOp.getFirstChild().isName()))) {

            Node replacementCond = replaceNode(originalCond, shortCond).detach();
            Node assignName = thenOp.removeFirstChild();
            Node thenExpr = thenOp.removeFirstChild();
            Node elseExpr = elseOp.getLastChild();
            elseOp.removeChild(elseExpr);

            Node hookNode = IR.hook(replacementCond, thenExpr, elseExpr)
                .srcref(n);
            Node assign = new Node(thenOp.getToken(), assignName, hookNode).srcref(thenOp);
            Node expr = NodeUtil.newExpr(assign);
            parent.replaceChild(n, expr);
            reportChangeToEnclosingScope(parent);

            return expr;
          }
        }
      }
      // if(x)foo();else bar(); -> x?foo():bar()
      Node replacementCond = replaceNode(originalCond, shortCond).detach();
      thenOp.detach();
      elseOp.detach();
      Node expr = IR.exprResult(
          IR.hook(replacementCond, thenOp, elseOp).srcref(n));
      parent.replaceChild(n, expr);
      reportChangeToEnclosingScope(parent);
      return expr;
    }

    boolean thenBranchIsVar = isVarBlock(thenBranch);
    boolean elseBranchIsVar = isVarBlock(elseBranch);

    // if(x)var y=1;else y=2  ->  var y=x?1:2
    if (thenBranchIsVar && elseBranchIsExpressionBlock
        && getBlockExpression(elseBranch).getFirstChild().isAssign()) {

      Node var = getBlockVar(thenBranch);
      Node elseAssign = getBlockExpression(elseBranch).getFirstChild();

      Node name1 = var.getFirstChild();
      Node maybeName2 = elseAssign.getFirstChild();

      if (name1.hasChildren()
          && maybeName2.isName()
          && name1.getString().equals(maybeName2.getString())) {
        checkState(name1.hasOneChild());
        Node thenExpr = name1.removeFirstChild();
        Node elseExpr = elseAssign.getLastChild().detach();
        Node replacementCond = replaceNode(originalCond, shortCond).detach();
        Node hookNode = IR.hook(replacementCond, thenExpr, elseExpr).srcref(n);
        var.detach();
        name1.addChildToBack(hookNode);
        parent.replaceChild(n, var);
        reportChangeToEnclosingScope(parent);
        return var;
      }

    // if(x)y=1;else var y=2  ->  var y=x?1:2
    } else if (elseBranchIsVar && thenBranchIsExpressionBlock
        && getBlockExpression(thenBranch).getFirstChild().isAssign()) {

      Node var = getBlockVar(elseBranch);
      Node thenAssign = getBlockExpression(thenBranch).getFirstChild();

      Node maybeName1 = thenAssign.getFirstChild();
      Node name2 = var.getFirstChild();

      if (name2.hasChildren()
          && maybeName1.isName()
          && maybeName1.getString().equals(name2.getString())) {
        Node thenExpr = thenAssign.getLastChild().detach();
        checkState(name2.hasOneChild());
        Node elseExpr = name2.removeFirstChild();
        Node replacementCond = replaceNode(originalCond, shortCond).detach();
        Node hookNode = IR.hook(replacementCond, thenExpr, elseExpr).srcref(n);
        var.detach();
        name2.addChildToBack(hookNode);
        parent.replaceChild(n, var);
        reportChangeToEnclosingScope(parent);

        return var;
      }
    }

    replaceNode(originalCond, unnegatedCond);
    return n;
  }
488748
@Override
    public void backward() {
        Tensor x = modInX.getOutput();
        double w_k = modInW.getOutput().getValue(k);
        {
            Tensor tmp = new Tensor(yAdj); // copy
            tmp.multiply(w_k);
            modInX.getOutputAdj().elemAdd(tmp);
        }
        {
            Tensor tmp = new Tensor(yAdj); // copy
            tmp.elemMultiply(x);
            modInW.getOutputAdj().addValue(k, tmp.getSum());
        }
    }
1096065
@Override
    public int drainTo(Collection<? super T> c, int maxElements) {

        //TODO- The elements aren't added to the given collection...

        if (c == null)
            throw new NullPointerException();
        if (c == this)
            throw new IllegalArgumentException();

        int n = Math.min(maxElements, size());

        int numRemaining = n;

        synchronized (this) {
            synchronized (lock) {
                //Retrieve and remove at most n elements from the expedited buffer and add them to the passed collection
                for (int i = 0; i < n; i++) {
                    T retrieved = expeditedExtract();
                    numRemaining = n - i;
                    if (retrieved != null) {
                        numberOfUsedExpeditedSlots.getAndDecrement();
                        //TODO if expedited is added for put or offer with timeout add notification here
                    } else {
                        break; //retrieved is null so nothing left in the expedited buffer, move on to the main buffer
                    }
                }
                //Retrieve and remove at most numRemaining elements and add them to the passed collection
                for (int i = 0; i < numRemaining; i++) {
                    T retrieved = extract();
                    numberOfUsedSlots.getAndDecrement();
                    if (retrieved != null) {
                        notifyPut_();
                    }
                }
            }
        }
        return n;
    }
599835
def linear(self, limits=None, k=5):
        """"""
        start, stop = limits or (self.minval, self.maxval)
        return np.linspace(start, stop, k)
37093
@Override
    public void backward() {
        Tensor x = modInX.getOutput();
        double w_k = modInW.getOutput().getValue(k);
        {
            Tensor tmp = new Tensor(yAdj); // copy
            tmp.divide(w_k);
            modInX.getOutputAdj().elemAdd(tmp);
        }
        {
            Tensor tmp = new Tensor(yAdj); // copy
            tmp.elemMultiply(x);
            tmp.divide(s.negate(s.times(w_k, w_k)));
            modInW.getOutputAdj().addValue(k, tmp.getSum());
        }
    }