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

Scala example source code file (spec-sparsearray.scala)

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

int, int, int,t, none, none, some, sparsearray, sparsearray, t, t, t:classmanifest

The Scala spec-sparsearray.scala source code

import scala.collection.mutable.MapLike

class SparseArray[@specialized(Int) T:ClassManifest] extends collection.mutable.Map[Int,T] with collection.mutable.MapLike[Int,T,SparseArray[T]] {
  override def get(x: Int) = {
    val ind = findOffset(x)
    if(ind < 0) None else Some(error("ignore"))
  }

  /**
   * Returns the offset into index and data for the requested vector
   * index.  If the requested index is not found, the return value is
   * negative and can be converted into an insertion point with -(rv+1).
   */
  private def findOffset(i : Int) : Int = {
    error("impl doesn't matter")
  }

  override def apply(i : Int) : T = { error("ignore") }
  override def update(i : Int, value : T) = error("ignore")
  override def empty = new SparseArray[T]
  def -=(ind: Int) = error("ignore")
  def +=(kv: (Int,T)) = error("ignore")
  override final def iterator = error("ignore")
}

Other Scala examples (source code examples)

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