Unique Index Per String
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Function;
import com.google.common.collect.MapMaker;

public class IniqueIndex  {

    private final AtomicLong counter = new AtomicLong();
    private final ConcurrentMap<String, Long> map = new MapMaker().makeComputingMap(new Function<CharSequence, Long>() {

        public Long apply(CharSequence cs) {
            return counter.incrementAndGet();

    public long resolve(CharSequence object) {
        return map.get(object);

insert the code here
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License