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

Scala example source code file (ReverseMap.scala)

This example Scala source code file (ReverseMap.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

array, companion, cont, cont, int, int, list, resettable, reversemap, reversemap, string, string

The Scala ReverseMap.scala source code

package scala.collection.parallel.benchmarks
package parallel_array







class ReverseMap(sz: Int, p: Int, what: String)
extends Resettable[Cont](sz, p, what, (i: Int) => new Cont(i),  new Array[Any](_), classOf[Cont]) {
  def companion = ReverseMap
  override def repetitionsPerRun = 100
  
  def runpar = pa.reverseMap(compl)
  def runseq = sequentialReverseMap(compl, sz)
  override def comparisonMap = collection.Map()
  
  val id = (c: Cont) => c
  val compl = (c: Cont) => {
    var in = c.in
    var i = 2
    while (i < 6) {
      if (in % i == 0) in = 0
      i += 1
    }
    if (in < 0) null
    else c
  }
}

object ReverseMap extends Companion {
  def benchName = "reverse-map";
  def apply(sz: Int, p: Int, what: String) = new ReverseMap(sz, p, what)
  override def comparisons = List()
  override def defaultSize = 100000
}











Other Scala examples (source code examples)

Here is a short list of links related to this Scala ReverseMap.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.