Package net.emaze.dysfunctional.numbers.operations

Examples of net.emaze.dysfunctional.numbers.operations.IntegerOperations


    }

    @Test//@Sample
    public void canReduceIntegersUsingSum() {
        Iterator<Integer> iterator = Iterations.iterator(1, 2, 3);
        Integer reduced = Reductions.reduce(iterator, new Sum<Integer, Integer, Integer>(new IntegerOperations()), 0);
        Assert.assertEquals(6, reduced.intValue());
    }
View Full Code Here


        new Average<O>(null);
    }

    @Test
    public void canSumUsingAPolicy() {
        final Average<Integer> average = new Average<Integer>(new IntegerOperations());
        final Pair<Integer, Long> sumAndCount = average.perform(Pair.of(0, 0l), 6);
        Assert.assertEquals(Pair.of(6, 1L), sumAndCount);
    }
View Full Code Here

    }

    @Test//@Sample
    public void canCalculateAverageWithReductions() {
        Iterator<Integer> iter = Iterations.iterator(1, 2, 3);
        Pair<Integer, Long> average = Reductions.reduce(iter, new Average<Integer>(new IntegerOperations()), Pair.of(0, 0l));
        Assert.assertEquals(2, average.first() / average.second());
    }
View Full Code Here

TOP

Related Classes of net.emaze.dysfunctional.numbers.operations.IntegerOperations

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.