Example usage for java.util.function UnaryOperator apply

List of usage examples for java.util.function UnaryOperator apply

Introduction

In this page you can find the example usage for java.util.function UnaryOperator apply.

Prototype

R apply(T t);

Source Link

Document

Applies this function to the given argument.

Usage

From source file:com.simiacryptus.mindseye.lang.Tensor.java

/**
 * Reorder dimensions tensor./*from ww  w  .ja  v  a  2  s  .  c  o  m*/
 *
 * @param fn the fn
 * @return the tensor
 */
@Nonnull
public Tensor rearrange(@Nonnull UnaryOperator<int[]> fn) {
    return rearrange(fn, fn.apply(getDimensions()));
}

From source file:com.simiacryptus.mindseye.lang.Tensor.java

/**
 * Reorder dimensions tensor./*from   ww  w . j ava2  s .c  o m*/
 *
 * @param fn         the fn
 * @param outputDims the output dims
 * @return the tensor
 */
@Nonnull
public Tensor rearrange(@Nonnull UnaryOperator<int[]> fn, int[] outputDims) {
    @Nonnull
    Tensor result = new Tensor(outputDims);
    coordStream(false).forEach(c -> {
        int[] inCoords = c.getCoords();
        int[] outCoords = fn.apply(inCoords);
        result.set(outCoords, get(c));
    });
    return result;
}

From source file:org.apache.commons.weaver.privilizer.example.MethodReferencesUsingBlueprints.java

public String utilsGetProperty(String key) {
    final UnaryOperator<String> o = Utils::getProperty;
    return o.apply(key);
}

From source file:org.apache.hyracks.maven.license.GenerateFileMojo.java

private void resolveContent(Project project, JarFile jarFile, JarEntry entry, UnaryOperator<String> transformer,
        BiConsumer<Project, String> contentConsumer, final String name) throws IOException {
    String text = IOUtils.toString(jarFile.getInputStream(entry), StandardCharsets.UTF_8);
    text = transformer.apply(text);
    text = LicenseUtil.trim(text);/*from   www .j  a  v a2  s  . c o  m*/
    if (text.length() == 0) {
        getLog().warn("Ignoring empty " + name + " file ( " + entry + ") for " + project.gav());
    } else {
        contentConsumer.accept(project, text);
        getLog().debug("Resolved " + name + " text for " + project.gav() + ": \n" + text);
    }
}

From source file:org.apache.jena.query.text.TextIndexLucene.java

private List<TextHit> query$(IndexReader indexReader, Node property, String qs,
        UnaryOperator<Query> textQueryExtender, String graphURI, String lang, int limit, String highlight)
        throws ParseException, IOException, InvalidTokenOffsetsException {
    String litField = docDef.getField(property) != null ? docDef.getField(property) : docDef.getPrimaryField();
    String textField = litField;//w  ww  . j a  v a2 s .c om
    String textClause = "";
    String langField = getDocDef().getLangField();

    List<String> searchForTags = Util.getSearchForTags(lang);
    boolean usingSearchFor = !searchForTags.isEmpty();
    if (usingSearchFor) {
        for (String tag : searchForTags) {
            String tf = textField + "_" + tag;
            textClause += tf + ":" + qs + " ";
        }
    } else {
        if (this.isMultilingual && StringUtils.isNotEmpty(lang) && !lang.equals("none")) {
            textField += "_" + lang;
            textClause = textField + ":" + qs;
        } else if (docDef.getField(property) != null) {
            textClause = textField + ":" + qs;
        } else {
            textClause = qs;
        }

        if (langField != null && StringUtils.isNotEmpty(lang)) {
            textClause = "(" + textClause + ") AND "
                    + (!lang.equals("none") ? langField + ":" + lang : "-" + langField + ":*");
        }
    }

    String queryString = textClause;

    if (graphURI != null) {
        String escaped = QueryParserBase.escape(graphURI);
        queryString = "(" + queryString + ") AND " + getDocDef().getGraphField() + ":" + escaped;
    }

    Analyzer qa = getQueryAnalyzer(usingSearchFor, lang);
    Query textQuery = parseQuery(queryString, qa);
    Query query = textQueryExtender.apply(textQuery);

    if (limit <= 0)
        limit = MAX_N;

    log.debug("Lucene queryString: {}, parsed query: {}, limit:{}", queryString, query, limit);

    IndexSearcher indexSearcher = new IndexSearcher(indexReader);

    ScoreDoc[] sDocs = indexSearcher.search(query, limit).scoreDocs;

    if (highlight != null) {
        return highlightResults(sDocs, indexSearcher, query, litField, highlight, usingSearchFor, lang);
    } else {
        return simpleResults(sDocs, indexSearcher, query, litField);
    }
}

From source file:org.briljantframework.array.AbstractArray.java

@Override
public void apply(UnaryOperator<T> operator) {
    for (int i = 0; i < size(); i++) {
        set(i, operator.apply(get(i)));
    }//from w w w  .j  a  v a2  s  .c  o  m
}

From source file:org.briljantframework.array.AbstractBooleanArray.java

@Override
public void apply(UnaryOperator<Boolean> operator) {
    for (int i = 0; i < size(); i++) {
        set(i, operator.apply(get(i)));
    }/*from   w  w w.j  a  v  a2 s  .  co  m*/
}

From source file:org.briljantframework.array.AbstractComplexArray.java

@Override
public ComplexArray assign(ComplexArray array, UnaryOperator<Complex> operator) {
    array = ShapeUtils.broadcastIfSensible(this, array);
    Check.size(this, array);
    for (int i = 0; i < size(); i++) {
        set(i, operator.apply(array.get(i)));
    }//  ww w.j  ava  2 s.com
    return this;
}

From source file:org.briljantframework.array.AbstractComplexArray.java

@Override
public ComplexArray map(UnaryOperator<Complex> operator) {
    ComplexArray m = newEmptyArray(getShape());
    for (int i = 0; i < size(); i++) {
        m.set(i, operator.apply(get(i)));
    }//  www.  j a  v a 2s  .co m
    return m;
}

From source file:org.briljantframework.array.AbstractComplexArray.java

@Override
public void apply(UnaryOperator<Complex> operator) {
    for (int i = 0; i < size(); i++) {
        set(i, operator.apply(get(i)));
    }//from   w  w  w  .j a v  a  2 s.  c om
}