package com.jxml.quick.recycle;
import java.util.*;

/**
 * A hash table keyed on identity.
 */
public final class QIdentityHash
{
	protected HashMap hash=new HashMap();

	public Object put(Object key, Object value)
	{
		if (value==null)
			return hash.remove(new I(key));
		return hash.put(new I(key),value);
	}

	public Object get(Object key)
	{
		return hash.get(new I(key));
	}

	static class I
	{
		Object key;

		I(Object key)
		{
			this.key=key;
		}

		public boolean equals(Object x)
		{
			return key==((I)x).key;
		}

		public int hashCode()
		{
			return System.identityHashCode(key);
		}
	}
}
