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

de.sciss.lucre.impl.PlainIdentMap.scala Maven / Gradle / Ivy

Go to download

Extension of Scala-STM, adding optional durability layer, and providing API for confluent and reactive event layers

There is a newer version: 4.6.6
Show newest version
/*
 *  PlainIdentMap.scala
 *  (Lucre 4)
 *
 *  Copyright (c) 2009-2021 Hanns Holger Rutz. All rights reserved.
 *
 *  This software is published under the GNU Affero General Public License v3+
 *
 *
 *  For further information, please contact Hanns Holger Rutz at
 *  [email protected]
 */

package de.sciss.lucre
package impl

import de.sciss.lucre.Plain.Id

import scala.collection.mutable

final class PlainIdentMap[A] extends IdentMap[Plain, A] {
  private[this] val peer = mutable.Map.empty[Id, A]

  def put(id: Id, value: A)(implicit tx: Plain): Unit = peer.put(id, value)

  def get(id: Id)(implicit tx: Plain): Option[A] = peer.get(id)

  def getOrElse(id: Id, default: => A)(implicit tx: Plain): A = peer.getOrElse(id, default)

  def contains(id: Id)(implicit tx: Plain): Boolean = peer.contains(id)

  def remove(id: Id)(implicit tx: Plain): Unit = peer.remove(id)

  def dispose()(implicit tx: Plain): Unit = peer.clear()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy