|
Scala example source code file (bug573.scala)
The Scala bug573.scala source codepackage lampion.collections; object DirX { abstract class Dir { def reverse : Dir; } object BEFORE extends Dir { def reverse = AFTER; } object AFTER extends Dir { def reverse = BEFORE; } } import DirX._; abstract class Linked { type Node <: Node0; abstract class Node0 { self: Node => var next : Node = _; var prev : Node = _; def get(dir : Dir) = if (dir == BEFORE) prev; else next; private def set(dir : Dir, node : Node) = if (dir == BEFORE) prev = node; else next = node; def link(dir : Dir, node : Node) = { assert(get(dir) == null); assert(node.get(dir.reverse) == null); set(dir, node); node.set(dir.reverse, self); } def end(dir : Dir) : Node = { if (get(dir) == null) this; else get(dir).end(dir); } } } Other Scala examples (source code examples)Here is a short list of links related to this Scala bug573.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 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.