Notes about the algorithm: We only create new datastructures if we need to, to keep perf impact reasonable.
336678
function applyProviderOverridesToNgModule(def) {
    var _a = calcHasOverrides(def), hasOverrides = _a.hasOverrides, hasDeprecatedOverrides = _a.hasDeprecatedOverrides;
    if (!hasOverrides) {
        return def;
    }
    // clone the whole view definition,
    // as it maintains references between the nodes that are hard to update.
    def = def.factory(function () { return NOOP; });
    applyProviderOverrides(def);
    return def;
    function calcHasOverrides(def) {
        var hasOverrides = false;
        var hasDeprecatedOverrides = false;
        if (providerOverrides.size === 0) {
            return { hasOverrides: hasOverrides, hasDeprecatedOverrides: hasDeprecatedOverrides };
        }
        def.providers.forEach(function (node) {
            var override = providerOverrides.get(node.token);
            if ((node.flags & 3840 /* CatProviderNoDirective */) && override) {
                hasOverrides = true;
                hasDeprecatedOverrides = hasDeprecatedOverrides || override.deprecatedBehavior;
            }
        });
        def.modules.forEach(function (module) {
            providerOverridesWithScope.forEach(function (override, token) {
                if (token.ngInjectableDef.providedIn === module) {
                    hasOverrides = true;
                    hasDeprecatedOverrides = hasDeprecatedOverrides || override.deprecatedBehavior;
                }
            });
        });
        return { hasOverrides: hasOverrides, hasDeprecatedOverrides: hasDeprecatedOverrides };
    }
    function applyProviderOverrides(def) {
        for (var i = 0; i < def.providers.length; i++) {
            var provider = def.providers[i];
            if (hasDeprecatedOverrides) {
                // We had a bug where me made
                // all providers lazy. Keep this logic behind a flag
                // for migrating existing users.
                provider.flags |= 4096 /* LazyProvider */;
            }
            var override = providerOverrides.get(provider.token);
            if (override) {
                provider.flags = (provider.flags & ~3840 /* CatProviderNoDirective */) | override.flags;
                provider.deps = splitDepsDsl(override.deps);
                provider.value = override.value;
            }
        }
        if (providerOverridesWithScope.size > 0) {
            var moduleSet_1 = new Set(def.modules);
            providerOverridesWithScope.forEach(function (override, token) {
                if (moduleSet_1.has(token.ngInjectableDef.providedIn)) {
                    var provider = {
                        token: token,
                        flags: override.flags | (hasDeprecatedOverrides ? 4096 /* LazyProvider */ : 0 /* None */),
                        deps: splitDepsDsl(override.deps),
                        value: override.value,
                        index: def.providers.length,
                    };
                    def.providers.push(provider);
                    def.providersByKey[tokenKey(token)] = provider;
                }
            });
        }
    }
}
1356637
def new(cls, alias, sealed_obj, algorithm, key, key_size):
        
        timestamp = int(time.time()) * 1000

        raise NotImplementedError("Creating Secret Keys not implemented")
745325
function createSectionStructure() {
    return {
        init: null,
        comments: [],
        attribs: {
            define: [],
            init: []
        },
        elements: {
            define: [],
            init: []
        },
        events: [],
        links: [],
        ons: [],
        statics: []
    };
}
563710
def lifecycle
      # Create a new metric to hold the task and conditions.
      m = Metric.new(self)

      # Let the config file define some conditions on the metric.
      yield(m)

      # Populate the condition -> metric directory.
      m.conditions.each do |c|
        self.directory[c] = m
      end

      # Record the metric.
      self.metrics[nil] << m
    end
632785
def _learnOnNewSegments(connections, rng, newSegmentCells, growthCandidates,
                          initialPermanence, sampleSize, maxSynapsesPerSegment):
    

    numNewSynapses = len(growthCandidates)

    if sampleSize != -1:
      numNewSynapses = min(numNewSynapses, sampleSize)

    if maxSynapsesPerSegment != -1:
      numNewSynapses = min(numNewSynapses, maxSynapsesPerSegment)

    newSegments = connections.createSegments(newSegmentCells)
    connections.growSynapsesToSample(newSegments, growthCandidates,
                                     numNewSynapses, initialPermanence,
                                     rng)
357621
function makeAcyclic(g) {
    var onStack = {};
    var visited = {};

    function dfs(u) {
      if (u in visited) {
        return;
      }
      visited[u] = true;
      onStack[u] = true;
      g.successors(u).forEach(function(v) {
        if (v in onStack) {
          g.addEdge(v, u);
          g.removeEdge(u, v);
        } else {
          dfs(v);
        }
      });
      delete onStack[u];
    }

    g.nodes().forEach(function(u) {
      dfs(u);
    });
  }
1267404
void buildForIncremental(final EncodingResult result, final Variable[] vars, int rhs) {
    cardinalityNetwork.buildAMKForIncremental(result, vars, rhs);
  }
653428
private boolean canOptimizeObjectCreate(Node firstParam) {
    Node curParam = firstParam;
    while (curParam != null) {
      if (!isOptimizableKey(curParam)) {
        return false;
      }
      curParam = curParam.getNext();

      // Check for an odd number of parameters.
      if (curParam == null) {
        return false;
      }
      curParam = curParam.getNext();
    }
    return true;
  }
1768
def incremental_neighbor_graph(X, precomputed=False, k=None, epsilon=None,
                               weighting='none'):
  ''''''
  assert ((k is not None) or (epsilon is not None)
          ), "Must provide `k` or `epsilon`"
  assert (_issequence(k) ^ _issequence(epsilon)
          ), "Exactly one of `k` or `epsilon` must be a sequence."
  assert weighting in ('binary','none'), "Invalid weighting param: " + weighting
  is_weighted = weighting == 'none'

  if precomputed:
    D = X
  else:
    D = pairwise_distances(X, metric='euclidean')
  # pre-sort for efficiency
  order = np.argsort(D)[:,1:]

  if k is None:
    k = D.shape[0]

  # generate the sequence of graphs
  # TODO: convert the core of these loops to Cython for speed
  W = np.zeros_like(D)
  I = np.arange(D.shape[0])
  if _issequence(k):
    # varied k, fixed epsilon
    if epsilon is not None:
      D[D > epsilon] = 0
    old_k = 0
    for new_k in k:
      idx = order[:, old_k:new_k]
      dist = D[I, idx.T]
      W[I, idx.T] = dist if is_weighted else 1
      yield Graph.from_adj_matrix(W)
      old_k = new_k
  else:
    # varied epsilon, fixed k
    idx = order[:,:k]
    dist = D[I, idx.T].T
    old_i = np.zeros(D.shape[0], dtype=int)
    for eps in epsilon:
      for i, row in enumerate(dist):
        oi = old_i[i]
        ni = oi + np.searchsorted(row[oi:], eps)
        rr = row[oi:ni]
        W[i, idx[i,oi:ni]] = rr if is_weighted else 1
        old_i[i] = ni
      yield Graph.from_adj_matrix(W)
313605
def structure_changes_from(current_structure = nil)
      new_structure = column
     
      if current_structure
        # General RDBMS data loss scenarios
        if new_structure[:limit] && current_structure[:limit].to_i != new_structure[:limit].to_i ||
           new_structure[:type] != current_structure[:type] ||
           !new_structure[:default].nil? && column_default_changed?(current_structure[:default], new_structure[:default])

           column
        else
          nil # No changes
        end
      else
        column
      end
    end
825476
private void minimize() {

        // Algorithm: compare each entry n to all subsequent entries in
        // the list: if any subsequent entry matches or widens entry n,
        // remove entry n. If any subsequent entries narrow entry n, remove
        // the subsequent entries.
        for (int i = 0; i < size(); i++) {
            GeneralNameInterface current = getGeneralNameInterface(i);
            boolean remove1 = false;

            /* compare current to subsequent elements */
            for (int j = i + 1; j < size(); j++) {
                GeneralNameInterface subsequent = getGeneralNameInterface(j);
                switch (current.constrains(subsequent)) {
                    case GeneralNameInterface.NAME_DIFF_TYPE:
                        /* not comparable; different name types; keep checking */
                        continue;
                    case GeneralNameInterface.NAME_MATCH:
                        /* delete one of the duplicates */
                        remove1 = true;
                        break;
                    case GeneralNameInterface.NAME_NARROWS:
                        /* subsequent narrows current */
                        /* remove narrower name (subsequent) */
                        remove(j);
                        j--; /* continue check with new subsequent */
                        continue;
                    case GeneralNameInterface.NAME_WIDENS:
                        /* subsequent widens current */
                        /* remove narrower name current */
                        remove1 = true;
                        break;
                    case GeneralNameInterface.NAME_SAME_TYPE:
                        /* keep both for now; keep checking */
                        continue;
                }
                break;
            } /* end of this pass of subsequent elements */

            if (remove1) {
                remove(i);
                i--; /* check the new i value */
            }

        }
    }
773514
private void dfs(Visitor visitor, int v, int[] cc, int id) {
        visitor.visit(v);
        cc[v] = id;
        for (int t = 0; t < n; t++) {
            if (graph[v][t] != 0.0) {
                if (cc[t] == -1) {
                    dfs(visitor, t, cc, id);
                }
            }
        }
    }
1002437
private boolean augment() {

        // reset data structures
        Arrays.fill(even, NIL);
        Arrays.fill(odd, NIL);
        dsf = new DisjointSetForest(graph.length);
        bridges.clear();
        queue.clear();

        // enqueue every unmatched vertex and place in the
        // even level (level = 0)
        for (int v = 0; v < graph.length; v++) {
            if (subset.get(v) && matching.unmatched(v)) {
                even[v] = v;
                queue.add(v);
            }
        }

        // for each 'free' vertex, start a bfs search
        while (!queue.isEmpty()) {
            int v = queue.remove(0);

            for (int w : graph[v]) {

                if (!subset.get(w)) continue;

                // the endpoints of the edge are both at even levels in the
                // forest - this means it is either an augmenting path or
                // a blossom
                if (even[dsf.getRoot(w)] != NIL) {
                    if (check(v, w)) return true;
                }

                // add the edge to the forest if is not already and extend
                // the tree with this matched edge
                else if (odd[w] == NIL) {
                    odd[w] = v;
                    int u = matching.other(w);
                    // add the matched edge (potential though a blossom) if it
                    // isn't in the forest already
                    if (even[dsf.getRoot(u)] == NIL) {
                        even[u] = w;
                        queue.add(u);
                    }
                }
            }
        }

        // no augmenting paths, matching is maximum
        return false;
    }
1173401
private boolean isUniqueImplied(StorableIndex<S> candidate) {
        if (candidate.isUnique()) {
            return true;
        }
        if (this.size() <= 1) {
            return false;
        }

        Set<StorableProperty<S>> candidateProps = new HashSet<StorableProperty<S>>();
        for (int i=candidate.getPropertyCount(); --i>=0; ) {
            candidateProps.add(candidate.getProperty(i));
        }

        search: for (StorableIndex<S> index : this) {
            if (!index.isUnique()) {
                continue search;
            }
            for (int i=index.getPropertyCount(); --i>=0; ) {
                if (!candidateProps.contains(index.getProperty(i))) {
                    continue search;
                }
            }
            return true;
        }

        return false;
    }
505668
def new(self, bootstrap_with=None, use_timer=False, with_proof=False):
        

        if not self.maplesat:
            self.maplesat = pysolvers.maplecm_new()

            if bootstrap_with:
                for clause in bootstrap_with:
                    self.add_clause(clause)

            self.use_timer = use_timer
            self.call_time = 0.0  # time spent for the last call to oracle
            self.accu_time = 0.0  # time accumulated for all calls to oracle

            if with_proof:
                self.prfile = tempfile.TemporaryFile()
                pysolvers.maplecm_tracepr(self.maplesat, self.prfile)
1262512
private void ensureCapacity(int newSize) {
        int oldSize;
        if ((oldSize = branchingEnumerators.length) < newSize) {
            branchingEnumerators = Arrays.copyOfRange(branchingEnumerators, 0, newSize);
            for (int i = oldSize; i < newSize; ++i)
                branchingEnumerators[i] = new BranchingEnumerator<>(reference, guide);
        }
    }
918150
def diff_cleanupEfficiency(self, diffs):
    
    changes = False
    equalities = []  # Stack of indices where equalities are found.
    lastEquality = None  # Always equal to diffs[equalities[-1]][1]
    pointer = 0  # Index of current position.
    pre_ins = False  # Is there an insertion operation before the last equality.
    pre_del = False  # Is there a deletion operation before the last equality.
    post_ins = False  # Is there an insertion operation after the last equality.
    post_del = False  # Is there a deletion operation after the last equality.
    while pointer < len(diffs):
      if diffs[pointer][0] == self.DIFF_EQUAL:  # Equality found.
        if (len(diffs[pointer][1]) < self.Diff_EditCost and
            (post_ins or post_del)):
          # Candidate found.
          equalities.append(pointer)
          pre_ins = post_ins
          pre_del = post_del
          lastEquality = diffs[pointer][1]
        else:
          # Not a candidate, and can never become one.
          equalities = []
          lastEquality = None

        post_ins = post_del = False
      else:  # An insertion or deletion.
        if diffs[pointer][0] == self.DIFF_DELETE:
          post_del = True
        else:
          post_ins = True

        # Five types to be split:
        # <ins>A</ins><del>B</del>XY<ins>C</ins><del>D</del>
        # <ins>A</ins>X<ins>C</ins><del>D</del>
        # <ins>A</ins><del>B</del>X<ins>C</ins>
        # <ins>A</del>X<ins>C</ins><del>D</del>
        # <ins>A</ins><del>B</del>X<del>C</del>

        if lastEquality and ((pre_ins and pre_del and post_ins and post_del) or
                             ((len(lastEquality) < self.Diff_EditCost / 2) and
                              (pre_ins + pre_del + post_ins + post_del) == 3)):
          # Duplicate record.
          diffs.insert(equalities[-1], (self.DIFF_DELETE, lastEquality))
          # Change second copy to insert.
          diffs[equalities[-1] + 1] = (self.DIFF_INSERT,
              diffs[equalities[-1] + 1][1])
          equalities.pop()  # Throw away the equality we just deleted.
          lastEquality = None
          if pre_ins and pre_del:
            # No changes made which could affect previous entry, keep going.
            post_ins = post_del = True
            equalities = []
          else:
            if len(equalities):
              equalities.pop()  # Throw away the previous equality.
            if len(equalities):
              pointer = equalities[-1]
            else:
              pointer = -1
            post_ins = post_del = False
          changes = True
      pointer += 1

    if changes:
      self.diff_cleanupMerge(diffs)