alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (WeakHashMap.scala)

This example Scala source code file (WeakHashMap.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

a, a, b, b, canbuildfrom, jmapwrapper, jmapwrapper, jmapwrapperlike, mapcanbuildfrom, mutablemapfactory, weakhashmap, weakhashmap

The Scala WeakHashMap.scala source code

/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2011, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */



package scala.collection
package mutable

import JavaConversions._
import generic._


/** A hash map with references to entries which are weakly reachable. Entries are
 *  removed from this map when the key is no longer (strongly) referenced. This class wraps
 *  `java.util.WeakHashMap`.
 *  
 *  @tparam A      type of keys contained in this map
 *  @tparam B      type of values associated with the keys
 *  
 *  @since 2.8
 *  @define Coll WeakHashMap
 *  @define coll weak hash map
 *  @define thatinfo the class of the returned collection. In the standard library configuration,
 *    `That` is always `WeakHashMap[A, B]` if the elements contained in the resulting collection are 
 *    pairs of type `(A, B)`. This is because an implicit of type `CanBuildFrom[WeakHashMap, (A, B), WeakHashMap[A, B]]`
 *    is defined in object `WeakHashMap`. Otherwise, `That` resolves to the most specific type that doesn't have
 *    to contain pairs of type `(A, B)`, which is `Iterable`.
 *  @define bfinfo an implicit value of class `CanBuildFrom` which determines the
 *    result class `That` from the current representation type `Repr`
 *    and the new element type `B`. This is usually the `canBuildFrom` value
 *    defined in object `WeakHashMap`.
 *  @define mayNotTerminateInf
 *  @define willNotTerminateInf
 */
class WeakHashMap[A, B] extends JMapWrapper[A, B](new java.util.WeakHashMap)
			   with JMapWrapperLike[A, B, WeakHashMap[A, B]] {
  override def empty = new WeakHashMap[A, B]
}

/** $factoryInfo
 *  @define Coll WeakHashMap
 *  @define coll weak hash map
 */
object WeakHashMap extends MutableMapFactory[WeakHashMap] {
  implicit def canBuildFrom[A, B]: CanBuildFrom[Coll, (A, B), WeakHashMap[A, B]] = new MapCanBuildFrom[A, B]
  def empty[A, B]: WeakHashMap[A, B] = new WeakHashMap[A, B]
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala WeakHashMap.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.