All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dotty.tools.dotc.util.ReadOnlySet.scala Maven / Gradle / Ivy

There is a newer version: 3.6.4-RC1-bin-20241220-0bfa1af-NIGHTLY
Show newest version
package dotty.tools.dotc.util

/** A class for the readonly part of mutable sets.
 */
abstract class ReadOnlySet[T]:

  /** The entry in the set such that `isEqual(x, entry)`, or else `null`. */
  def lookup(x: T): T | Null

  def size: Int

  def iterator: Iterator[T]

  def contains(x: T): Boolean = lookup(x) != null

  def foreach[U](f: T => U): Unit = iterator.foreach(f)

  def toList: List[T] = iterator.toList

  def isEmpty = size == 0

object ReadOnlySet:
  def empty[T]: ReadOnlySet[T] = HashSet[T](4)





© 2015 - 2025 Weber Informatics LLC | Privacy Policy