Move the implicit BitSet=>Ordered[BitSet] coercion to
automata/SubsetConstruction, where it is used git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@5645 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
8371b87201
commit
e7829ff427
|
@ -38,36 +38,3 @@ class BitSet(val size: Int, val capacity: Int, ba: Array[Int], copy: Boolean)
|
|||
ba;
|
||||
|
||||
}
|
||||
|
||||
object BitSet {
|
||||
implicit def toOrdered(bs: BitSet): Ordered[BitSet] = new Ordered[BitSet] {
|
||||
def compareTo [b >: BitSet <% Ordered[b]](other: b): Int = other match {
|
||||
case that: BitSet => {
|
||||
val it1 = bs.elements;
|
||||
val it2 = that.elements;
|
||||
var res = 0;
|
||||
while((0 == res) && it1.hasNext) {
|
||||
while((0 == res) && it2.hasNext) {
|
||||
if (!it1.hasNext)
|
||||
res = -1
|
||||
else {
|
||||
val i1 = it1.next;
|
||||
val i2 = it2.next;
|
||||
if (i1 < i2)
|
||||
res = -1
|
||||
else if (i1 > i2)
|
||||
res = 1
|
||||
}
|
||||
}
|
||||
if (it1.hasNext)
|
||||
res = 1
|
||||
}
|
||||
if (it2.hasNext)
|
||||
res = -1;
|
||||
res
|
||||
}
|
||||
|
||||
//case _ => -(other.compareTo(this))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,43 @@
|
|||
package scala.util.automata ;
|
||||
|
||||
class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) {
|
||||
|
||||
//import nfa.{ _labelT, labels };
|
||||
import nfa.labels ;
|
||||
import scala.collection.{immutable, mutable, Map} ;
|
||||
|
||||
import immutable.{ BitSet, TreeMap, TreeSet } ;
|
||||
|
||||
implicit def toOrdered(bs: BitSet): Ordered[BitSet] = new Ordered[BitSet] {
|
||||
def compareTo [b >: BitSet <% Ordered[b]](other: b): Int = other match {
|
||||
case that: BitSet => {
|
||||
val it1 = bs.elements;
|
||||
val it2 = that.elements;
|
||||
var res = 0;
|
||||
while((0 == res) && it1.hasNext) {
|
||||
while((0 == res) && it2.hasNext) {
|
||||
if (!it1.hasNext)
|
||||
res = -1
|
||||
else {
|
||||
val i1 = it1.next;
|
||||
val i2 = it2.next;
|
||||
if (i1 < i2)
|
||||
res = -1
|
||||
else if (i1 > i2)
|
||||
res = 1
|
||||
}
|
||||
}
|
||||
if (it1.hasNext)
|
||||
res = 1
|
||||
}
|
||||
if (it2.hasNext)
|
||||
res = -1;
|
||||
res
|
||||
}
|
||||
|
||||
//case _ => -(other.compareTo(this))
|
||||
}
|
||||
}
|
||||
|
||||
/** the set {0} */
|
||||
final val _initialBitSet = {
|
||||
val rbs = new mutable.BitSet(1);
|
||||
|
|
Loading…
Reference in New Issue