Scala fragments: Shortest-paths algorithms

Dijkstra's algorithm is reasonably easy to implement, but it requires a priority queue with priorities which can be modified efficiently. This is best represented as a priority map, where the ordering of the elements is based on priority, but indexing is based on the data stored.

PriorityMap stores keys of any type, and orders them against an integer priority. The interface is simple: items may be pushed into the queue, or popped off the end of the queue. Pushing a key which is already contained within the structure will reassign its priority. Lower numbers indicate higher priority. These semantics are based on those used by a very similar priority dictionary for Python.

Scala fragments: Generic Object Interning

Interning for Strings (permanently storing only one copy of a String, such that duplicates of that String refer to the same actual memory region) operates in the background without the developer ever being aware of it. Java Strings are immutable, making this safe. RefStore.scala implements a generic interning facility for your objects; obviously you should really only use this with immutable objects.

Scala fragments: Remote Actors

Remote Actors allow near-transparent message exchange between Scala Actors located on different physical hosts. I wrote some example code for these Scala libraries, detailed in this blog post; RemoteSource.scala and RemoteSink.scala contain the source code in the blog post.