home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (SortedMap.scala)

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

Learn more about this Scala project at its project page.

Java - Scala tags/keywords

buildkeyconstraint, canbuildfrom, mapsubfunctions, mapsubinstances, mapsubsortedmap, order, xmap

The SortedMap.scala Scala example source code

package scalaz
package std

import collection.immutable.SortedMap
import collection.generic.CanBuildFrom

sealed trait MapSubSortedMap {
  type XMap[K, V] = SortedMap[K, V]
  type BuildKeyConstraint[K] = Order[K]

  protected final def buildXMap[K, V, K2: BuildKeyConstraint, V2]
      : CanBuildFrom[XMap[K, V], (K2, V2), XMap[K2, V2]] = {
    implicit val so = Order[K2].toScalaOrdering

  protected final def ab_+[K: BuildKeyConstraint, V
                         ](m: XMap[K, V], k: K, v: V): XMap[K, V] =
    m updated (k, v)

  protected final def ab_-[K: BuildKeyConstraint, V
                         ](m: XMap[K, V], k: K): XMap[K, V] =
    m - k

object sortedMap extends MapSubInstances with MapSubFunctions
    with MapSubSortedMap

Other Scala examples (source code examples)

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

my book on functional programming


new blog posts


Copyright 1998-2019 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.