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

com.blazebit.persistence.impl.function.CyclicUnsignedCounter Maven / Gradle / Ivy

There is a newer version: 1.2.0-Alpha1
Show newest version
package com.blazebit.persistence.impl.function;

public class CyclicUnsignedCounter {

    private int value = Integer.MIN_VALUE;

    public CyclicUnsignedCounter() {
    }

    public CyclicUnsignedCounter(int value) {
        this.value = value;
    }

    public int incrementAndGet() {
        return value = (value + 1) & Integer.MAX_VALUE;
    }

    public int getAndIncrement() {
        int temp = value;
        value = (value + 1) & Integer.MAX_VALUE;
        return temp;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy