summaryrefslogblamecommitdiff
path: root/sources/scala/collection/mutable/HashSet.scala
blob: 8b68a9aa9d4209320513ee6f0f85605272b27ab9 (plain) (tree)
1
2
3
4
5
6
7
8
9








                                                                          
                                 
 




                                                         
   
                                                                            





















                                                            
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003, LAMP/EPFL                  **
**  __\ \/ /__/ __ |/ /__/ __ |                                         **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
** $Id$
\*                                                                      */

package scala.collection.mutable;


/** This class implements mutable sets using a hashtable.
 *
 *  @author  Matthias Zenger
 *  @version 1.0, 08/07/2003
 */
class HashSet[A] extends scala.collection.mutable.Set[A] with HashTable[A] {

    def contains(elem: A): Boolean = findEntry(elem) match {
        case None => false
        case Some(_) => true
    }

    def add(elem: A): Unit = findEntry(elem) match {
        case None => addEntry(elem);
        case Some(_) =>
    }

    def elements = entries;

    override def clear = {
        initTable(table.length - 1);
        tableSize = 0;
    }

    protected type Entry = A;

    protected def entryKey(e: Entry) = e;
}