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

com.poiji.save.OrderedValues Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package com.poiji.save;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public final class OrderedValues {

    private final Collection busyOrders;

    public OrderedValues(final Collection busyOrders) {
        this.busyOrders = busyOrders;
    }

    public  Map toOrder(final Collection unorderedValues) {
        final Map ordered = new HashMap<>();
        int order = 0;
        for (final T name : unorderedValues) {
            while (busyOrders.contains(order)) {
                order++;
            }
            ordered.put(name, order++);
        }
        return ordered;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy