
org.javafunk.funk.Sequences Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of funk-core Show documentation
Show all versions of funk-core Show documentation
Functional utilities for Java: core APIs
The newest version!
/*
* Copyright (C) 2011-Present Funk committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
* style license a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.javafunk.funk;
import org.javafunk.funk.datastructures.IntegerRange;
public class Sequences {
private Sequences() {}
private enum Direction {
ASCENDING(+1), DESCENDING(-1);
private int multiplier;
Direction(int multiplier) {
this.multiplier = multiplier;
}
int getMultiplier() {
return multiplier;
}
}
public static Direction increasing() {
return Direction.ASCENDING;
}
public static Direction decreasing() {
return Direction.DESCENDING;
}
public static Iterable integers(Direction direction) {
return new IntegerRange(0, null, direction.getMultiplier());
}
public static Iterable integersFrom(int startPoint, Direction direction) {
return new IntegerRange(startPoint, null, direction.getMultiplier());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy