See {@link #compute(MealyMachine, Alphabet, Set)}. Internal version, that uses the {@link SplitTree}
representation.
773600
static <S, I, O> Optional<ADSNode<S, I, O>> compute(final MealyMachine<S, I, ?, O> automaton,
                                                        final Alphabet<I> input,
                                                        final SplitTree<S, I, O> node) {
        return compute(automaton, input, node, node.getPartition().size());
    }
635313
@Override
	public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input)
			throws Exception {
		// s, d(s), 1/log(d(s))
		DataSet<Tuple3<K, LongValue, FloatValue>> inverseLogDegree = input
			.run(new VertexDegree<K, VV, EV>()
				.setParallelism(parallelism))
			.map(new VertexInverseLogDegree<>())
				.setParallelism(parallelism)
				.name("Vertex score");

		// s, t, 1/log(d(s))
		DataSet<Tuple3<K, K, FloatValue>> sourceInverseLogDegree = input
			.getEdges()
			.join(inverseLogDegree, JoinHint.REPARTITION_HASH_SECOND)
			.where(0)
			.equalTo(0)
			.projectFirst(0, 1)
			.<Tuple3<K, K, FloatValue>>projectSecond(2)
				.setParallelism(parallelism)
				.name("Edge score");

		// group span, s, t, 1/log(d(s))
		DataSet<Tuple4<IntValue, K, K, FloatValue>> groupSpans = sourceInverseLogDegree
			.groupBy(0)
			.sortGroup(1, Order.ASCENDING)
			.reduceGroup(new GenerateGroupSpans<>())
				.setParallelism(parallelism)
				.name("Generate group spans");

		// group, s, t, 1/log(d(s))
		DataSet<Tuple4<IntValue, K, K, FloatValue>> groups = groupSpans
			.rebalance()
				.setParallelism(parallelism)
				.name("Rebalance")
			.flatMap(new GenerateGroups<>())
				.setParallelism(parallelism)
				.name("Generate groups");

		// t, u, 1/log(d(s)) where (s, t) and (s, u) are edges in graph
		DataSet<Tuple3<K, K, FloatValue>> twoPaths = groups
			.groupBy(0, 1)
			.sortGroup(2, Order.ASCENDING)
			.reduceGroup(new GenerateGroupPairs<>())
				.name("Generate group pairs");

		// t, u, adamic-adar score
		GroupReduceOperator<Tuple3<K, K, FloatValue>, Result<K>> scores = twoPaths
			.groupBy(0, 1)
			.reduceGroup(new ComputeScores<>(minimumScore, minimumRatio))
				.name("Compute scores");

		if (minimumRatio > 0.0f) {
			// total score, number of pairs of neighbors
			DataSet<Tuple2<FloatValue, LongValue>> sumOfScoresAndNumberOfNeighborPairs = inverseLogDegree
				.map(new ComputeScoreFromVertex<>())
					.setParallelism(parallelism)
					.name("Average score")
				.sum(0)
				.andSum(1);

			scores
				.withBroadcastSet(sumOfScoresAndNumberOfNeighborPairs, SUM_OF_SCORES_AND_NUMBER_OF_NEIGHBOR_PAIRS);
		}

		if (mirrorResults) {
			return scores
				.flatMap(new MirrorResult<>())
					.name("Mirror results");
		} else {
			return scores;
		}
	}
691954
public static final <S, E> Functional<S> functionalSet(Set<E> set) {
		return new FunctionalSet<S, E>(set);
	}
387952
@Override
  public V computeIfAbsent(final K key, final Callable<V> callable) {
    Entry<K,V> e;
    for (;;) {
      e = lookupOrNewEntry(key);
      if (e.hasFreshData(clock)) {
        return returnValue(e);
      }
      synchronized (e) {
        e.waitForProcessing();
        if (e.hasFreshData(clock)) {
          return returnValue(e);
        }
        if (e.isGone()) {
          metrics.goneSpin();
          continue;
        }
        e.startProcessing(Entry.ProcessingState.COMPUTE);
        break;
      }
    }
    metrics.peekMiss();
    boolean _finished = false;
    long t = 0, t0 = 0;
    V _value;
    try {
      if (!isUpdateTimeNeeded()) {
        _value = callable.call();
      } else {
        t0 = clock.millis();
        _value = callable.call();
        if (!metrics.isDisabled()) {
          t = clock.millis();
        }
      }
      synchronized (e) {
        insertOrUpdateAndCalculateExpiry(e, _value, t0, t, t0, INSERT_STAT_PUT);
        e.processingDone();
      }
      _finished = true;

    } catch (RuntimeException ex) {
      throw ex;
    } catch (Exception ex) {
      throw new CacheLoaderException(ex);
    } finally {
      e.ensureAbort(_finished);
    }
    return returnValue(e);
  }
203197
public Set<T> internAll(Set<T> s) {
    Set<T> result = Generics.newHashSet();
    for (T o : s) {
      result.add(intern(o));
    }
    return result;
  }
234608
static <S, I, O> Optional<ADSNode<S, I, O>> compute(final MealyMachine<S, I, ?, O> automaton,
                                                        final Alphabet<I> input,
                                                        final SplitTree<S, I, O> node) {

        final Iterator<S> targetStateIterator = node.getPartition().iterator();
        final S s1 = targetStateIterator.next();
        final S s2 = targetStateIterator.next();

        final Word<I> separatingWord = Automata.findSeparatingWord(automaton, s1, s2, input);

        // sep word may be non existent, if current hypothesis is not consistent
        if (separatingWord == null) {
            return Optional.empty();
        }

        final Word<O> s1Output = automaton.computeStateOutput(s1, separatingWord);
        final Word<O> s2Output = automaton.computeStateOutput(s2, separatingWord);
        final Word<O> sharedOutput = s1Output.longestCommonPrefix(s2Output);
        final Word<I> trace = separatingWord.prefix(sharedOutput.length() + 1);

        final Pair<ADSNode<S, I, O>, ADSNode<S, I, O>> ads = ADSUtil.buildFromTrace(automaton, trace, s1);

        final ADSNode<S, I, O> head = ads.getFirst();
        final ADSNode<S, I, O> tail = ads.getSecond();

        final ADSNode<S, I, O> s1FinalNode = new ADSLeafNode<>(tail, node.getMapping().get(s1));
        final ADSNode<S, I, O> s2FinalNode = new ADSLeafNode<>(tail, node.getMapping().get(s2));

        tail.getChildren().put(s1Output.getSymbol(sharedOutput.length()), s1FinalNode);
        tail.getChildren().put(s2Output.getSymbol(sharedOutput.length()), s2FinalNode);

        return Optional.of(head);
    }
1270290
function divideSet(set, setSize) {
  if (!setSize) {
    throw new Error(`Set Division by 0`)
  }
  let thisSet = new Set()
  let remainingItems = setSize
  const output = [thisSet]
  const iterator = set.values()
  // @ts-ignore
  for (const value of iterator) {
    if (remainingItems === 0) {
      thisSet = new Set()
      remainingItems = setSize
      output.push(thisSet)
    }
    thisSet.add(value)
    remainingItems--
  }
  return output
}
888737
protected static boolean computeAnd (Iterable<Value<Boolean>> values)
    {
        for (Value<Boolean> value : values) {
            if (!value.get()) {
                return false;
            }
        }
        return true;
    }
3716
public void addSet(final SortedSet<T> set) {
        SortedMap<T, UBNode<T>> nodes = rootNodes;
        UBNode<T> node = null;
        for (T element : set) {
            node = nodes.get(element);
            if (node == null) {
                node = new UBNode<>(element);
                nodes.put(element, node);
            }
            nodes = node.children();
        }
        if (node != null) {
            node.setEndSet(set);
        }
    }
1282606
public MealyMachine<?, String, ?, String> runExperiment1() {
        // For each membership query a new instance of BoundedStringQueue will
        // be created (normal learning scenario without filters)
        FullMembershipQueryOracle oracle = new FullMembershipQueryOracle();

        // construct L* instance (almost classic Mealy version)
        // almost: we use words (Word<String>) in cells of the table
        // instead of single outputs.
        MealyLearner<String, String> lstar;
        lstar = new ExtensibleLStarMealyBuilder<String, String>().withAlphabet(sigma)
                                                                 .withInitialSuffixes(initialSuffixes)
                                                                 .withOracle(oracle)
                                                                 .create();

        lstar.startLearning();
        MealyMachine<?, String, ?, String> result;
        result = lstar.getHypothesisModel();

        System.out.println("Resets:  " + oracle.resets);
        System.out.println("Symbols: " + oracle.symbols);

        return result;
    }
1194719
@Override
    public <R, A> R collect(Collector<? super T, A, R> collector) {
        Predicate<A> finished = finished(collector);
        if (finished != null) {
            BiConsumer<A, ? super T> acc = collector.accumulator();
            BinaryOperator<A> combiner = collector.combiner();
            Spliterator<T> spliterator = spliterator();
            if (!isParallel()) {
                A a = collector.supplier().get();
                if (!finished.test(a)) {
                    try {
                        // forEachRemaining can be much faster
                        // and take much less memory than tryAdvance for certain
                        // spliterators
                        spliterator.forEachRemaining(e -> {
                            acc.accept(a, e);
                            if (finished.test(a))
                                throw new CancelException();
                        });
                    } catch (CancelException ex) {
                        // ignore
                    }
                }
                return collector.finisher().apply(a);
            }
            Spliterator<A> spltr;
            if (!spliterator.hasCharacteristics(Spliterator.ORDERED)
                || collector.characteristics().contains(Characteristics.UNORDERED)) {
                spltr = new UnorderedCancellableSpliterator<>(spliterator, collector.supplier(), acc, combiner,
                        finished);
            } else {
                spltr = new OrderedCancellableSpliterator<>(spliterator, collector.supplier(), acc, combiner, finished);
            }
            return collector.finisher().apply(
                new StreamEx<>(StreamSupport.stream(spltr, true), context).findFirst().get());
        }
        return rawCollect(collector);
    }
1319771
@Override public void compute2() {
    if(Job.isRunning(_jobKey)) {
      Timer timer    = new Timer();
      _stats[0]      = new ThreadLocal<hex.singlenoderf.Statistic>();
      _stats[1]      = new ThreadLocal<hex.singlenoderf.Statistic>();
      Data d = _sampler.sample(_data, _seed, _modelKey, _local_mode);
      hex.singlenoderf.Statistic left = getStatistic(0, d, _seed, _exclusiveSplitLimit);
      // calculate the split
      for( Row r : d ) left.addQ(r, _regression);
      if (!_regression)
        left.applyClassWeights();   // Weight the distributions
      hex.singlenoderf.Statistic.Split spl = left.split(d, false);
      if(spl.isLeafNode()) {
        if(_regression) {
          float av = d.computeAverage();
          _tree = new LeafNode(-1, d.rows(), av);
        } else {
          _tree =  new LeafNode(_data.unmapClass(spl._split), d.rows(),-1);
        }
      } else {
        _tree = new FJBuild (spl, d, 0, _seed).compute();
      }

      _stats = null; // GC
      if(_jobKey != null && !Job.isRunning(_jobKey)) throw new Job.JobCancelledException();

      // Atomically improve the Model as well
      Key tkey = toKey();
      Key dtreeKey = null;
      if (_score_pojo) dtreeKey = toCompressedKey();
      appendKey(_modelKey, tkey, dtreeKey, _verbose > 10 ? _tree.toString(new StringBuilder(""), Integer.MAX_VALUE).toString() : "", _data_id);
//      appendKey(_modelKey, tkey, _verbose > 10 ? _tree.toString(new StringBuilder(""), Integer.MAX_VALUE).toString() : "", _data_id);
      StringBuilder sb = new StringBuilder("[RF] Tree : ").append(_data_id+1);
      sb.append(" d=").append(_tree.depth()).append(" leaves=").append(_tree.leaves()).append(" done in ").append(timer).append('\n');
      Log.info(sb.toString());
      if (_verbose > 10) {
//        Log.info(Sys.RANDF, _tree.toString(sb, Integer.MAX_VALUE).toString());
//        Log.info(Sys.RANDF, _tree.toJava(sb, Integer.MAX_VALUE).toString());
      }
    } else throw new Job.JobCancelledException();
    // Wait for completion
    tryComplete();
  }
1166083
public <T> void putComputationalData(Class<T> key, T value) {
        this.computationalData.put(key, value);
    }
894246
public SharedTreeGraph _computeGraph(int treeToPrint) {
        SharedTreeGraph g = new SharedTreeGraph();

        if (treeToPrint >= _ntree_groups) {
            throw new IllegalArgumentException("Tree " + treeToPrint + " does not exist (max " + _ntree_groups + ")");
        }

        int j;
        if (treeToPrint >= 0) {
            j = treeToPrint;
        }
        else {
            j = 0;
        }

        for (; j < _ntree_groups; j++) {
            for (int i = 0; i < _ntrees_per_group; i++) {
                int itree = treeIndex(j, i);
                String[] domainValues = isSupervised() ? getDomainValues(getResponseIdx()) : null;
                String treeName = treeName(j, i, domainValues);
                SharedTreeSubgraph sg = g.makeSubgraph(treeName);
                computeTreeGraph(sg, _compressed_trees[itree], _compressed_trees_aux[itree],
                        getNames(), getDomainValues());
            }

            if (treeToPrint >= 0) {
                break;
            }
        }

        return g;
    }
1351565
public static final <T> Set<T> symmetricDifference(Collection<Set<T>> sets)
    {
        MapSet<T,Integer> mapSet = new HashMapSet<>();
        int index = 0;
        for (Set<T> set : sets)
        {
            for (T t : set)
            {
                mapSet.add(t, index);
            }
            index++;
        }
        final Set<T> diff = new HashSet<>();
        mapSet.forEach((t,s)->{if (s.size() == 1) diff.add(t);});
        return diff;
    }
723738
public static <T> ImmutableSortedSet<ImmutableSortedSet<T>> immutablePowerSet(SortedSet<T> set)
    {
        return powerSet(set).collect(new Function<MutableSortedSet<T>, ImmutableSortedSet<T>>()
        {
            public ImmutableSortedSet<T> valueOf(MutableSortedSet<T> set)
            {
                return set.toImmutable();
            }
        }, TreeSortedSet.<ImmutableSortedSet<T>>newSet(Comparators.<T>powerSet())).toImmutable();
    }
1043847
public static <E, S extends SortedSet<E>> SynchronizedSortedSet<E> of(S set)
    {
        return new SynchronizedSortedSet<E>(SortedSetAdapter.adapt(set));
    }