All Downloads are FREE. Search and download functionalities are using the official Maven repository.

netflix.ocelli.functions.Functions Maven / Gradle / Ivy

There is a newer version: 0.1.0-rc.2
Show newest version
package netflix.ocelli.functions;

import rx.functions.Func1;

public abstract class Functions {
    public static Func1 log() {
        return new Func1() {
            @Override
            public Integer call(Integer t1) {
                return (int)Math.ceil(Math.log(t1));
            }
        };
    }
    
    public static Func1 memoize(final Integer value) {
        return new Func1() {
            @Override
            public Integer call(Integer t1) {
                return Math.min(value, t1);
            }
        };
    }
    
    public static Func1 log_log() {
        return new Func1() {
            @Override
            public Integer call(Integer t1) {
                return (int)Math.ceil(Math.log(Math.log(t1)));
            }
        };
    }
    
    public static Func1 identity() {
        return new Func1() {
            @Override
            public Integer call(Integer t1) {
                return t1;
            }
        };
    }
    
    public static Func1 sqrt() {
        return new Func1() {
            @Override
            public Integer call(Integer t1) {
                return (int)Math.ceil(Math.sqrt((double)t1));
            }
        };
    }

    public static Func1 root(final double pow) {
        return new Func1() {
            @Override
            public Integer call(Integer t1) {
                return (int)Math.ceil(Math.pow((double)t1, 1/pow));
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy