All Projects → TangXiaoLv → Hfunc

TangXiaoLv / Hfunc

Licence: apache-2.0
java implement Higher-order function ,support map,filter , reduce with parallel, android

Programming Languages

java
68154 projects - #9 most used programming language

Labels

Projects that are alternatives of or similar to Hfunc

cdc
☣️ Shell plugin for zsh/bash that allows you to cd to subdirectories of user-defined directories from anywhere, without editing CDPATH.
Stars: ✭ 17 (-84.82%)
Mutual labels:  function
Recipe
Collection of PHP Functions
Stars: ✭ 666 (+494.64%)
Mutual labels:  function
Cartesian Product
PHP - A simple, low-memory footprint function to generate all combinations from a multi-dimensionnal array.
Stars: ✭ 58 (-48.21%)
Mutual labels:  function
Function2
Improved and configurable drop-in replacement to std::function that supports move only types, multiple overloads and more
Stars: ✭ 290 (+158.93%)
Mutual labels:  function
Funky
Funky takes shell functions to the next level by making them easier to define, more flexible, and more interactive.
Stars: ✭ 434 (+287.5%)
Mutual labels:  function
Webify
Turn shell commands into web services
Stars: ✭ 852 (+660.71%)
Mutual labels:  function
parse-function
(!! moved to tunnckoCore/opensource multi-package repository !!) 🔱 Parse a function into an object using espree, acorn or babylon parsers. Extensible through Smart Plugins.
Stars: ✭ 37 (-66.96%)
Mutual labels:  function
Spek
🎏 Function builder BDD testing framework in Swift
Stars: ✭ 104 (-7.14%)
Mutual labels:  function
Gomonkey
gomonkey is a library to make monkey patching in unit tests easy
Stars: ✭ 473 (+322.32%)
Mutual labels:  function
Gormt
database to golang struct
Stars: ✭ 1,063 (+849.11%)
Mutual labels:  function
Serving
Kubernetes-based, scale-to-zero, request-driven compute
Stars: ✭ 4,238 (+3683.93%)
Mutual labels:  function
Functional widget
A code generator to write widgets as function without loosing the benefits of classes.
Stars: ✭ 374 (+233.93%)
Mutual labels:  function
Sharpmath
A small .NET math library.
Stars: ✭ 36 (-67.86%)
Mutual labels:  function
Revisited
🧑‍🤝‍🧑 The visitor pattern revisited. An inheritance-aware acyclic visitor template, any and any-function templates.
Stars: ✭ 14 (-87.5%)
Mutual labels:  function
Shellfuncs
Python API to execute shell functions as they would be Python functions
Stars: ✭ 96 (-14.29%)
Mutual labels:  function
touch-callable
Automatically generate a Web UI for Python function using type annotations.
Stars: ✭ 36 (-67.86%)
Mutual labels:  function
Ccalc
Scientific calculator in which you can define new constants and functions
Stars: ✭ 19 (-83.04%)
Mutual labels:  function
Playwright Aws Lambda
Support for running Microsoft's Playwright on AWS Lambda and Google Cloud Functions
Stars: ✭ 107 (-4.46%)
Mutual labels:  function
Func Loc
A simple tool that helps you to retrieve the function location from its reference.
Stars: ✭ 99 (-11.61%)
Mutual labels:  function
Href Counter
Golang multi-stage build to count links within a page for SEO
Stars: ✭ 42 (-62.5%)
Mutual labels:  function

HFunc

Download

English | 中文

A fast and simple Java Higher-order function lib. Support serial compute and parallel compute. Applies to Java and Android.

Support

  • map
  • filter
  • reduce

Gradle

dependencies {
    compile 'com.library.tangxiaolv:hfunc:1.0.1'
}

Guide

Example:
//data collection
List<Integer> c = new ArrayList<>();
for (int i = 1; i < 101; i++) {
    c.add(i);
}

map:

serial compute: 1078ms
List<String> result = HFunc.map(c, new HFunc.Func1<Integer, String>() {
    @Override
    public String call(Integer item) {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {}
        return Integer.toString(item * 2);
    }
});

parallel compute: 150ms
List<String> result = HFunc.mapParallel(c, new HFunc.Func1<Integer, String>() {
    @Override
    public String call(Integer item) {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {}
        return Integer.toString(item * 2);
    }
});

filter:

serial compute: 1037ms
List<Integer> result = HFunc.filter(c, new HFunc.Func1<Integer, Boolean>() {
    @Override
    public Boolean call(Integer item) {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {}
        return item % 2 != 0;
    }
});
        
parallel compute: 159ms
List<Integer> result = HFunc.filterParallel(c, new HFunc.Func1<Integer, Boolean>() {
    @Override
    public Boolean call(Integer item) {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {}
        return item % 2 != 0;
    }
});

reduce:

serial compute: 1061ms
Integer result = HFunc.reduce(c, new HFunc.Func2<Integer, Integer, Integer>() {
    @Override
    public Integer call(Integer merge, Integer next) {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {}
        return merge + next;
    }
});

parallel compute: 239ms
Integer result = HFunc.reduceParallel(c, new HFunc.Func2<Integer, Integer, Integer>() {
    @Override
    public Integer call(Integer merge, Integer next) {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {}
        return merge + next;
    }
});

LICENSE

Copyright 2016 XiaoLv Tang

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].