package keris.lang;

import java.util.*;


public module IDENTITIES {
    
    /** a hashtable of all enumerated objects
     */
    private Map repository = new WeakHashMap();
    
    private int identities = 0;
    
    /** get the ID of an object
     */
    public synchronized int get(Object obj) {
        Integer id = (Integer)repository.get(obj);
        if (id == null) {
            repository.put(obj, new Integer(identities++));
            return identities - 1;
        } else
            return id.intValue();
    }
}
