<pre>
{@code
PersistentList<Integer> q = Reducers.toPersistentList()
.foldMap(Stream.of(1,2,3,4));

}
</pre>
@return Reducer for PersistentList
199021
public static <T> Reducer<PersistentList<T>,T> toPersistentList() {
        return Reducer.<PersistentList<T>,T> of(Seq.empty(), (final PersistentList<T> a) -> b -> b.plusAll(a), (final T x) -> Seq.of(x));

    }
1253165
public alluxio.grpc.PersistCommandOptionsOrBuilder getPersistOptionsOrBuilder() {
    return persistOptions_ == null ? alluxio.grpc.PersistCommandOptions.getDefaultInstance() : persistOptions_;
  }
701507
public Stream<T> orderedNodes() {
        TopoSorter<T> sorter = new TopoSorter<>(this);
        return sorter.result.stream();
    }
530039
public synchronized Map<String, List<Integer>> getList() {
    final Map<String, List<Integer>> tasks = new LinkedHashMap<>();

    tasks.put("Running", getTaskIdList(runningTasks));
    tasks.put("Waiting", getTaskIdList(taskQueue));
    tasks.put("Finished", getTaskIdList(finishedTasks));
    tasks.put("Canceled", getTaskIdList(canceledTasks));

    return tasks;
  }
1158430
@Override
    public ListT<W,T> sorted() {

        return (ListT<W,T>) FoldableTransformerSeq.super.sorted();
    }
483313
public PersistenceManager getPersistenceManager() {
        if (persistenceManager == null) {
            try {
                persistenceManager = getPresentationManager().newPersistenceManager();
            } catch (Exception ex) {
                getPresentationManager().error(ex);
                throw new ConnectionNotFoundException();
            }
        }
        return persistenceManager;
    }
464223
public static <T> Reducer<PersistentSet<T>,T> toPersistentSet() {
        return Reducer.fromMonoid(Monoids.concatPersistentCollection(HashSet.empty()), a -> HashSet.of(a));
    }
1133116
public List<PersistenceContextRefType<ApplicationDescriptor>> getAllPersistenceContextRef()
   {
      List<PersistenceContextRefType<ApplicationDescriptor>> list = new ArrayList<PersistenceContextRefType<ApplicationDescriptor>>();
      List<Node> nodeList = model.get("persistence-context-ref");
      for(Node node: nodeList)
      {
         PersistenceContextRefType<ApplicationDescriptor>  type = new PersistenceContextRefTypeImpl<ApplicationDescriptor>(this, "persistence-context-ref", model, node);
         list.add(type);
      }
      return list;
   }
512661
@Override
    public Iterator<T> iterator() {
        Iterator<T> transformed = Iterators.transform(rows.iterator(), row -> {
            T value = mapper.map(row);
            mapper.mappingComplete();
            return value;
        });
        mapper.mappingComplete();
        return transformed;
    }
433862
static <T> ReferencePipeline<T, T> makeRef(AbstractPipeline<?, T, ?> upstream) {
        return new ReferencePipeline.StatefulOp<T, T>(upstream, StreamShape.REFERENCE,
                                                      StreamOpFlag.IS_DISTINCT | StreamOpFlag.NOT_SIZED) {

            <P_IN> Node<T> reduce(PipelineHelper<T> helper, Spliterator<P_IN> spliterator) {
                // If the stream is SORTED then it should also be ORDERED so the following will also
                // preserve the sort order
                TerminalOp<T, LinkedHashSet<T>> reduceOp
                        = ReduceOps.<T, LinkedHashSet<T>>makeRef(LinkedHashSet::new, LinkedHashSet::add,
                                                                 LinkedHashSet::addAll);
                return Nodes.node(reduceOp.evaluateParallel(helper, spliterator));
            }

            @Override
            public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
                                              Spliterator<P_IN> spliterator,
                                              IntFunction<T[]> generator) {
                if (StreamOpFlag.DISTINCT.isKnown(helper.getStreamAndOpFlags())) {
                    // No-op
                    return helper.evaluate(spliterator, false, generator);
                }
                else if (StreamOpFlag.ORDERED.isKnown(helper.getStreamAndOpFlags())) {
                    return reduce(helper, spliterator);
                }
                else {
                    // Holder of null state since ConcurrentHashMap does not support null values
                    AtomicBoolean seenNull = new AtomicBoolean(false);
                    ConcurrentHashMap<T, Boolean> map = new ConcurrentHashMap<>();
                    TerminalOp<T, Void> forEachOp = ForEachOps.makeRef(t -> {
                        if (t == null)
                            seenNull.set(true);
                        else
                            map.putIfAbsent(t, Boolean.TRUE);
                    }, false);
                    forEachOp.evaluateParallel(helper, spliterator);

                    // If null has been seen then copy the key set into a HashSet that supports null values
                    // and add null
                    Set<T> keys = map.keySet();
                    if (seenNull.get()) {
                        // TODO Implement a more efficient set-union view, rather than copying
                        keys = new HashSet<>(keys);
                        keys.add(null);
                    }
                    return Nodes.node(keys);
                }
            }

            @Override
            public <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper, Spliterator<P_IN> spliterator) {
                if (StreamOpFlag.DISTINCT.isKnown(helper.getStreamAndOpFlags())) {
                    // No-op
                    return helper.wrapSpliterator(spliterator);
                }
                else if (StreamOpFlag.ORDERED.isKnown(helper.getStreamAndOpFlags())) {
                    // Not lazy, barrier required to preserve order
                    return reduce(helper, spliterator).spliterator();
                }
                else {
                    // Lazy
                    return new StreamSpliterators.DistinctSpliterator<>(helper.wrapSpliterator(spliterator));
                }
            }

            @Override
            public Sink<T> opWrapSink(int flags, Sink<T> sink) {
                Objects.requireNonNull(sink);

                if (StreamOpFlag.DISTINCT.isKnown(flags)) {
                    return sink;
                } else if (StreamOpFlag.SORTED.isKnown(flags)) {
                    return new Sink.ChainedReference<T, T>(sink) {
                        boolean seenNull;
                        T lastSeen;

                        @Override
                        public void begin(long size) {
                            seenNull = false;
                            lastSeen = null;
                            downstream.begin(-1);
                        }

                        @Override
                        public void end() {
                            seenNull = false;
                            lastSeen = null;
                            downstream.end();
                        }

                        @Override
                        public void accept(T t) {
                            if (t == null) {
                                if (!seenNull) {
                                    seenNull = true;
                                    downstream.accept(lastSeen = null);
                                }
                            } else if (lastSeen == null || !t.equals(lastSeen)) {
                                downstream.accept(lastSeen = t);
                            }
                        }
                    };
                } else {
                    return new Sink.ChainedReference<T, T>(sink) {
                        Set<T> seen;

                        @Override
                        public void begin(long size) {
                            seen = new HashSet<>();
                            downstream.begin(-1);
                        }

                        @Override
                        public void end() {
                            seen = null;
                            downstream.end();
                        }

                        @Override
                        public void accept(T t) {
                            if (!seen.contains(t)) {
                                seen.add(t);
                                downstream.accept(t);
                            }
                        }
                    };
                }
            }
        };
    }
1075089
public List<PersistenceUnit<Persistence<T>>> getAllPersistenceUnit()
   {
      List<PersistenceUnit<Persistence<T>>> list = new ArrayList<PersistenceUnit<Persistence<T>>>();
      List<Node> nodeList = childNode.get("persistence-unit");
      for(Node node: nodeList)
      {
         PersistenceUnit<Persistence<T>>  type = new PersistenceUnitImpl<Persistence<T>>(this, "persistence-unit", childNode, node);
         list.add(type);
      }
      return list;
   }
1039224
public MapReduceOptions<T> reduce(final String reduce) {
        Assert.parametersNotNull("reduce", reduce);
        Assert.parameterNotEmpty("reduce", reduce);
        this.reduce = reduce;
        return this;
    }
282607
public List<PersistenceUnit<PersistenceDescriptor>> getAllPersistenceUnit()
   {
      List<PersistenceUnit<PersistenceDescriptor>> list = new ArrayList<PersistenceUnit<PersistenceDescriptor>>();
      List<Node> nodeList = model.get("persistence-unit");
      for(Node node: nodeList)
      {
         PersistenceUnit<PersistenceDescriptor>  type = new PersistenceUnitImpl<PersistenceDescriptor>(this, "persistence-unit", model, node);
         list.add(type);
      }
      return list;
   }
977225
public MapFactory<E, MutableInteger> getMapFactory() {
    return ErasureUtils.<MapFactory<E,MutableInteger>>uncheckedCast(mapFactory);
  }
764680
@Override
  public <T> Streamlet<T> flatMap(
      SerializableFunction<R, ? extends Iterable<? extends T>> flatMapFn) {
    checkNotNull(flatMapFn, "flatMapFn cannot be null");

    FlatMapStreamlet<R, T> retval = new FlatMapStreamlet<>(this, flatMapFn);
    addChild(retval);
    return retval;
  }
1320103
public ListIterator<E> listIterator() {
        Object[] snapshot = elements;
        return new CowIterator<E>(snapshot, 0, snapshot.length);
    }
1148143
public HashMap<TopologyAPI.StreamId, List<Grouping>> getStreamConsumers() {
    if (this.streamConsumers == null) {
      this.streamConsumers = new HashMap<>();

      // First get a map of (TopologyAPI.StreamId -> TopologyAPI.StreamSchema)
      Map<TopologyAPI.StreamId, TopologyAPI.StreamSchema> streamToSchema =
          new HashMap<>();

      // Calculate spout's output stream
      for (TopologyAPI.Spout spout : this.getTopology().getSpoutsList()) {
        for (TopologyAPI.OutputStream outputStream : spout.getOutputsList()) {
          streamToSchema.put(outputStream.getStream(), outputStream.getSchema());
        }
      }

      // Calculate bolt's output stream
      for (TopologyAPI.Bolt bolt : this.getTopology().getBoltsList()) {
        for (TopologyAPI.OutputStream outputStream : bolt.getOutputsList()) {
          streamToSchema.put(outputStream.getStream(), outputStream.getSchema());
        }
      }

      // Only bolts could consume from input stream
      for (TopologyAPI.Bolt bolt : this.getTopology().getBoltsList()) {
        for (TopologyAPI.InputStream inputStream : bolt.getInputsList()) {
          TopologyAPI.StreamSchema schema = streamToSchema.get(inputStream.getStream());

          String componentName = bolt.getComp().getName();

          List<Integer> taskIds = this.getComponentToTaskIds().get(componentName);

          if (!this.streamConsumers.containsKey(inputStream.getStream())) {
            this.streamConsumers.put(inputStream.getStream(), new ArrayList<>());
          }

          this.streamConsumers.get(inputStream.getStream()).add(Grouping.create(
              inputStream.getGtype(),
              inputStream,
              schema,
              taskIds)
          );
        }
      }
    }

    return this.streamConsumers;
  }