Scala Library: scala.collection.parallel.mutable.ParFlatHashTable
scala.collection.parallel.mutable.ParFlatHashTable
trait ParFlatHashTable[T] extends FlatHashTable[T]
Parallel flat hash table.
- T
- type of the elements in the table.
- Source
Type Members
abstract class ParFlatHashTableIterator extends IterableSplitter[T] with SizeMapUtils
Value Members From scala.collection.mutable.FlatHashTable
def addElem(elem: T): Boolean
Add elem if not yet in table.
- returns
- Returns
true
if a new elem was added,false
otherwise.
- Returns
- Attributes
- protected
- Definition Classes
- FlatHashTable
(defined at scala.collection.mutable.FlatHashTable)
def addEntry(newEntry: AnyRef): Boolean
Add an entry (an elem converted to an entry via elemToEntry) if not yet in table.
- returns
- Returns
true
if a new elem was added,false
otherwise.
- Returns
- Attributes
- protected
- Definition Classes
- FlatHashTable
(defined at scala.collection.mutable.FlatHashTable)
def calcSizeMapSize(tableLength: Int): Int
- Attributes
- protected
- Definition Classes
- FlatHashTable
- Annotations
- @ deprecatedOverriding (message =…, since = “2.11.0”)
(defined at scala.collection.mutable.FlatHashTable)
def capacity(expectedSize: Int): Int
- Attributes
- protected
- Definition Classes
- FlatHashTable
(defined at scala.collection.mutable.FlatHashTable)
def containsElem(elem: T): Boolean
Checks whether an element is contained in the hash table.
- Attributes
- protected
- Definition Classes
- FlatHashTable
- Annotations
- @ deprecatedOverriding (message =…, since = “2.11.0”)
(defined at scala.collection.mutable.FlatHashTable)
def findEntry(elem: T): Option[T]
Finds an entry in the hash table if such an element exists.
- Attributes
- protected
- Definition Classes
- FlatHashTable
- Annotations
- @ deprecatedOverriding (message =…, since = “2.11.0”)
(defined at scala.collection.mutable.FlatHashTable)
final def index(hcode: Int): Int
- Attributes
- protected
- Definition Classes
- FlatHashTable
(defined at scala.collection.mutable.FlatHashTable)
def initWithContents(c: Contents[T]): Unit
- Attributes
- protected
- Definition Classes
- FlatHashTable
(defined at scala.collection.mutable.FlatHashTable)
def iterator: Iterator[T]
- Attributes
- protected
- Definition Classes
- FlatHashTable
(defined at scala.collection.mutable.FlatHashTable)
def nnSizeMapAdd(h: Int): Unit
- Attributes
- protected
- Definition Classes
- FlatHashTable
- Annotations
- @ deprecatedOverriding (message =…, since = “2.11.0”)
(defined at scala.collection.mutable.FlatHashTable)
def nnSizeMapRemove(h: Int): Unit
- Attributes
- protected
- Definition Classes
- FlatHashTable
- Annotations
- @ deprecatedOverriding (message =…, since = “2.11.0”)
(defined at scala.collection.mutable.FlatHashTable)
def nnSizeMapReset(tableLength: Int): Unit
- Attributes
- protected
- Definition Classes
- FlatHashTable
- Annotations
- @ deprecatedOverriding (message =…, since = “2.11.0”)
(defined at scala.collection.mutable.FlatHashTable)
def removeElem(elem: T): Boolean
Removes an elem from the hash table returning true if the element was found (and thus removed) or false if it didn’t exist.
- Attributes
- protected
- Definition Classes
- FlatHashTable
(defined at scala.collection.mutable.FlatHashTable)
def sizeMapInit(tableLength: Int): Unit
- Attributes
- protected
- Definition Classes
- FlatHashTable
- Annotations
- @ deprecatedOverriding (message =…, since = “2.11.0”)
(defined at scala.collection.mutable.FlatHashTable)
Value Members From scala.collection.mutable.FlatHashTable.HashUtils
final def elemToEntry(elem: T): AnyRef
Elems have type A, but we store AnyRef in the table. Plus we need to deal with null elems, which need to be stored as NullSentinel
- Attributes
- protected
- Definition Classes
- HashUtils
(defined at scala.collection.mutable.FlatHashTable.HashUtils)
final def entryToElem(entry: AnyRef): T
Does the inverse translation of elemToEntry
- Attributes
- protected
- Definition Classes
- HashUtils
(defined at scala.collection.mutable.FlatHashTable.HashUtils)
final def improve(hcode: Int, seed: Int): Int
- Attributes
- protected
- Definition Classes
- HashUtils
(defined at scala.collection.mutable.FlatHashTable.HashUtils)
Value Members From Implicit scala.collection.parallel.CollectionsHaveToParArray ——————————————————————————–
def toParArray: ParArray[T]
- Implicit information
- This member is added by an implicit conversion from ParFlatHashTable [T] to CollectionsHaveToParArray [ParFlatHashTable [T], T] performed by method CollectionsHaveToParArray in scala.collection.parallel. This conversion will take place only if an implicit value of type (ParFlatHashTable [T]) ⇒ GenTraversableOnce [T] is in scope.
- Definition Classes
- CollectionsHaveToParArray (added by implicit convertion: scala.collection.parallel.CollectionsHaveToParArray)
Full Source:
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala
package collection
package parallel.mutable
import scala.collection.parallel.IterableSplitter
/** Parallel flat hash table.
*
* @tparam T type of the elements in the $coll.
* @define coll table
* @define Coll `ParFlatHashTable`
*
* @author Aleksandar Prokopec
*/
trait ParFlatHashTable[T] extends scala.collection.mutable.FlatHashTable[T] {
override def alwaysInitSizeMap = true
abstract class ParFlatHashTableIterator(var idx: Int, val until: Int, val totalsize: Int)
extends IterableSplitter[T] with SizeMapUtils {
import scala.collection.DebugUtils._
private[this] var traversed = 0
private[this] val itertable = table
if (hasNext) scan()
private[this] def scan() {
while (itertable(idx) eq null) {
idx += 1
}
}
def newIterator(index: Int, until: Int, totalsize: Int): IterableSplitter[T]
def remaining = totalsize - traversed
def hasNext = traversed < totalsize
def next() = if (hasNext) {
val r = entryToElem(itertable(idx))
traversed += 1
idx += 1
if (hasNext) scan()
r
} else Iterator.empty.next()
def dup = newIterator(idx, until, totalsize)
def split = if (remaining > 1) {
val divpt = (until + idx) / 2
val fstidx = idx
val fstuntil = divpt
val fsttotal = calcNumElems(idx, divpt, itertable.length, sizeMapBucketSize)
val fstit = newIterator(fstidx, fstuntil, fsttotal)
val sndidx = divpt
val snduntil = until
val sndtotal = remaining - fsttotal
val sndit = newIterator(sndidx, snduntil, sndtotal)
Seq(fstit, sndit)
} else Seq(this)
override def debugInformation = buildString {
append =>
append("Parallel flat hash table iterator")
append("---------------------------------")
append("Traversed/total: " + traversed + " / " + totalsize)
append("Table idx/until: " + idx + " / " + until)
append("Table length: " + itertable.length)
append("Table: ")
append(arrayString(itertable, 0, itertable.length))
append("Sizemap: ")
append(arrayString(sizemap, 0, sizemap.length))
}
protected def countElems(from: Int, until: Int) = {
var count = 0
var i = from
while (i < until) {
if (itertable(i) ne null) count += 1
i += 1
}
count
}
protected def countBucketSizes(frombucket: Int, untilbucket: Int) = {
var count = 0
var i = frombucket
while (i < untilbucket) {
count += sizemap(i)
i += 1
}
count
}
}
}
Interested in Scala?
I send out weekly, personalized emails with articles and conference talks.
Subscribe now.