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

org.opentripplanner.routing.util.IncrementingIdGenerator Maven / Gradle / Ivy

package org.opentripplanner.routing.util;


/**
 * Generates unique identifiers by incrementing an internal counter.
 * 
 * @author avi
 */
public class IncrementingIdGenerator implements UniqueIdGenerator {
    
    private int next;
    
    public IncrementingIdGenerator() {
        this(0);
    }
    
    /**
     * Construct with a starting counter. 
     * 
     * First call to next() will return start.
     * 
     * @param start
     */
    public IncrementingIdGenerator(int start) {
        next = start;
    }
    
    /**
     * Generates the next identifier.
     * 
     * @return 
     */
    public int getId(T elem) {
        return next++;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy