package java.util;


public class HashSet extends /*sk13*/AbstractSet
    /*sk13*/ /*extends Hashtable*/
		//currently null is not permitted!!!!
{
		private Hashtable m_HashTable=null;

		public HashSet()
			{
				m_HashTable=new Hashtable();
			}

		public HashSet(Collection c)
			{
				m_HashTable=new Hashtable(Math.max(11,c.size()*2));
				addAll(c);
			}

		public HashSet(int initialCapacity, float loadFactor)
			{
				m_HashTable=new Hashtable(initialCapacity,loadFactor);
			}

		public HashSet(int initialCapacity)
			{
				m_HashTable=new Hashtable(initialCapacity);
			}

    public Iterator iterator()
      {
        return new HashSetIterator(this);
			}

		public int size()
			{
				return m_HashTable.size();
			}

	   public boolean contains(Object o)
      {
			  return m_HashTable.containsKey(o);
			}

	public boolean add(
        Object  o)
    {
        if (/*sk13*/m_HashTable.get(o) == null)
        {
            /*sk13*/m_HashTable.put(o, o);
            return true;
        }

        return false;
    }

		public boolean remove(Object o)
			{
				return (m_HashTable.remove(o)!=null);
			}

		public void clear()
			{
				m_HashTable.clear();
			}


		public Object clone()
			{
				HashSet hs=new HashSet();
				hs.m_HashTable=(Hashtable)m_HashTable.clone();
			  return hs;
			}

		private class HashSetIterator implements Iterator
			{
				Enumeration m_enum=null;
			  HashSet m_hs=null;
				Object m_currentElement=null;

				HashSetIterator(HashSet hs)
					{
						m_hs=hs;
						m_enum=hs.m_HashTable.elements();
						m_currentElement=null;
					}

				public boolean hasNext()
					{
						return m_enum.hasMoreElements();
					}

				public Object next()
					{
						m_currentElement=m_enum.nextElement();
					  return m_currentElement;
					}

				public void remove()// throws UnsupportedOperationException,IllegalStateException;
				  {
						m_hs.remove(m_currentElement);
					}
	}
}
