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

de.sciss.lucre.impl.PlainInMemoryMap.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
/*
 *  PlainInMemoryMap.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 scala.collection.mutable

final class PlainInMemoryMap[K, V] extends RefMap[Plain, K, V] {
  private[this] val peer = mutable.Map.empty[K, V]

  def put     (key: K, value: V )(implicit tx: Plain): Option[V]  = peer.put      (key, value)
  def remove  (key: K           )(implicit tx: Plain): Option[V]  = peer.remove   (key)
  def contains(key: K           )(implicit tx: Plain): Boolean    = peer.contains (key)
  def get     (key: K           )(implicit tx: Plain): Option[V]  = peer.get      (key)
  def size                       (implicit tx: Plain): Int        = peer.size
  def isEmpty                    (implicit tx: Plain): Boolean    = peer.isEmpty

  def foreach[B](f: ((K, V)) => B)(implicit tx: Plain): Unit = peer.foreach[B](f)

  def toMap(implicit tx: Plain): Map[K, V] = peer.toMap[K, V]
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy