Created
January 26, 2013 19:46
-
-
Save alextp/4644129 to your computer and use it in GitHub Desktop.
Revisions
-
alextp created this gist
Jan 26, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ class StringMapCubbie[T](val m: mutable.Map[String,T]) extends Cubbie { setMap(new mutable.Map[String, Any] { override def update(key: String, value: Any): Unit = { value match { case v: T => m(key) = v case _ => throw new InvalidClassException(value.getClass.getName + " is not of the proper type.") } } def += (kv: (String, Any)): this.type = { update(kv._1, kv._2); this } def -= (key: String): this.type = sys.error("Can't remove slots from cubbie map!") def get(key: String): Option[Any] = if (m.contains(key)) Some(m(key)) else None def iterator: Iterator[(String, Any)] = m.iterator }) }