author | wenzelm |
Mon, 07 Jun 2010 11:42:32 +0200 | |
changeset 37352 | c4f393759c59 |
parent 37185 | 64da21a2c6c7 |
child 38368 | 07bc80bdeebc |
permissions | -rw-r--r-- |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
1 |
/* Title: Pure/General/linear_set.scala |
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
3 |
Author: Fabian Immler, TU Munich |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
4 |
|
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
5 |
Sets with canonical linear order, or immutable linked-lists. |
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
6 |
*/ |
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
7 |
|
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
8 |
package isabelle |
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
9 |
|
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
10 |
import scala.collection.SetLike |
36781 | 11 |
import scala.collection.generic.{ImmutableSetFactory, CanBuildFrom, |
12 |
GenericSetTemplate, GenericCompanion} |
|
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
13 |
|
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
14 |
|
36781 | 15 |
object Linear_Set extends ImmutableSetFactory[Linear_Set] |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
16 |
{ |
32465 | 17 |
private case class Rep[A]( |
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
18 |
val start: Option[A], val end: Option[A], val nexts: Map[A, A], prevs: Map[A, A]) |
32465 | 19 |
|
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
20 |
private def empty_rep[A] = Rep[A](None, None, Map(), Map()) |
32465 | 21 |
|
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
22 |
private def make[A](start: Option[A], end: Option[A], nexts: Map[A, A], prevs: Map[A, A]) |
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
23 |
: Linear_Set[A] = new Linear_Set[A] { override val rep = Rep(start, end, nexts, prevs) } |
32465 | 24 |
|
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
25 |
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Linear_Set[A]] = setCanBuildFrom[A] |
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
26 |
override def empty[A] = new Linear_Set[A] |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
27 |
|
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
28 |
class Duplicate(s: String) extends Exception(s) |
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
29 |
class Undefined(s: String) extends Exception(s) |
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
30 |
} |
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
31 |
|
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
32 |
|
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
33 |
class Linear_Set[A] |
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
34 |
extends scala.collection.immutable.Set[A] |
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
35 |
with GenericSetTemplate[A, Linear_Set] |
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
36 |
with SetLike[A, Linear_Set[A]] |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
37 |
{ |
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
38 |
override def companion: GenericCompanion[Linear_Set] = Linear_Set |
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
39 |
|
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
40 |
|
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
41 |
/* representation */ |
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
42 |
|
32465 | 43 |
protected val rep = Linear_Set.empty_rep[A] |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
44 |
|
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
45 |
|
32465 | 46 |
/* auxiliary operations */ |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
47 |
|
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
48 |
def next(elem: A): Option[A] = rep.nexts.get(elem) |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
49 |
def prev(elem: A): Option[A] = rep.prevs.get(elem) |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
50 |
|
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
51 |
def insert_after(hook: Option[A], elem: A): Linear_Set[A] = |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
52 |
if (contains(elem)) throw new Linear_Set.Duplicate(elem.toString) |
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
53 |
else |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
54 |
hook match { |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
55 |
case None => |
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
56 |
rep.start match { |
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
57 |
case None => Linear_Set.make(Some(elem), Some(elem), Map(), Map()) |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
58 |
case Some(elem1) => |
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
59 |
Linear_Set.make(Some(elem), rep.end, |
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
60 |
rep.nexts + (elem -> elem1), rep.prevs + (elem1 -> elem)) |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
61 |
} |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
62 |
case Some(elem1) => |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
63 |
if (!contains(elem1)) throw new Linear_Set.Undefined(elem1.toString) |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
64 |
else |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
65 |
rep.nexts.get(elem1) match { |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
66 |
case None => |
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
67 |
Linear_Set.make(rep.start, Some(elem), |
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
68 |
rep.nexts + (elem1 -> elem), rep.prevs + (elem -> elem1)) |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
69 |
case Some(elem2) => |
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
70 |
Linear_Set.make(rep.start, rep.end, |
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
71 |
rep.nexts + (elem1 -> elem) + (elem -> elem2), |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
72 |
rep.prevs + (elem2 -> elem) + (elem -> elem1)) |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
73 |
} |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
74 |
} |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
75 |
|
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
76 |
def delete_after(hook: Option[A]): Linear_Set[A] = |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
77 |
hook match { |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
78 |
case None => |
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
79 |
rep.start match { |
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
80 |
case None => throw new Linear_Set.Undefined("") |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
81 |
case Some(elem1) => |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
82 |
rep.nexts.get(elem1) match { |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
83 |
case None => empty |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
84 |
case Some(elem2) => |
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
85 |
Linear_Set.make(Some(elem2), rep.end, rep.nexts - elem1, rep.prevs - elem2) |
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
86 |
} |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
87 |
} |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
88 |
case Some(elem1) => |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
89 |
if (!contains(elem1)) throw new Linear_Set.Undefined(elem1.toString) |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
90 |
else |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
91 |
rep.nexts.get(elem1) match { |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
92 |
case None => throw new Linear_Set.Undefined("") |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
93 |
case Some(elem2) => |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
94 |
rep.nexts.get(elem2) match { |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
95 |
case None => |
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
96 |
Linear_Set.make(rep.start, Some(elem1), rep.nexts - elem1, rep.prevs - elem2) |
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
97 |
case Some(elem3) => |
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
98 |
Linear_Set.make(rep.start, rep.end, |
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
99 |
rep.nexts - elem2 + (elem1 -> elem3), |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
100 |
rep.prevs - elem2 + (elem3 -> elem1)) |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
101 |
} |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
102 |
} |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
103 |
} |
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
104 |
|
32577
892ebdaf19b4
added append_after (tuned version of former insert_after of Seq);
wenzelm
parents:
32576
diff
changeset
|
105 |
def append_after(hook: Option[A], elems: Seq[A]): Linear_Set[A] = |
37185
64da21a2c6c7
avoid :\ which is not tail-recursive and tends to overflow the tiny JVM stack, which is not resizable at runtime;
wenzelm
parents:
37072
diff
changeset
|
106 |
((hook, this) /: elems) { |
64da21a2c6c7
avoid :\ which is not tail-recursive and tends to overflow the tiny JVM stack, which is not resizable at runtime;
wenzelm
parents:
37072
diff
changeset
|
107 |
case ((last_elem, set), elem) => (Some(elem), set.insert_after(last_elem, elem)) |
64da21a2c6c7
avoid :\ which is not tail-recursive and tends to overflow the tiny JVM stack, which is not resizable at runtime;
wenzelm
parents:
37072
diff
changeset
|
108 |
}._2 |
32577
892ebdaf19b4
added append_after (tuned version of former insert_after of Seq);
wenzelm
parents:
32576
diff
changeset
|
109 |
|
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
110 |
def delete_between(from: Option[A], to: Option[A]): Linear_Set[A] = |
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
111 |
{ |
32591 | 112 |
if (isEmpty) this |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
113 |
else { |
32465 | 114 |
val next = |
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
115 |
if (from == rep.end) None |
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
116 |
else if (from == None) rep.start |
32576
20b261654e33
double linking for improved performance of "prev";
wenzelm
parents:
32465
diff
changeset
|
117 |
else from.map(rep.nexts(_)) |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
118 |
if (next == to) this |
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
119 |
else delete_after(from).delete_between(from, to) |
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
120 |
} |
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
121 |
} |
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
122 |
|
32465 | 123 |
|
124 |
/* Set methods */ |
|
125 |
||
126 |
override def stringPrefix = "Linear_Set" |
|
127 |
||
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
128 |
override def isEmpty: Boolean = !rep.start.isDefined |
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
129 |
override def size: Int = if (isEmpty) 0 else rep.nexts.size + 1 |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
130 |
|
34304 | 131 |
def contains(elem: A): Boolean = |
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
132 |
!isEmpty && (rep.end.get == elem || rep.nexts.isDefinedAt(elem)) |
34304 | 133 |
|
37070 | 134 |
private def make_iterator(start: Option[A], which: Map[A, A]): Iterator[A] = new Iterator[A] { |
34304 | 135 |
private var next_elem = start |
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
136 |
def hasNext = next_elem.isDefined |
34301 | 137 |
def next = |
138 |
next_elem match { |
|
139 |
case Some(elem) => |
|
37070 | 140 |
next_elem = which.get(elem) |
34301 | 141 |
elem |
142 |
case None => throw new NoSuchElementException("next on empty iterator") |
|
143 |
} |
|
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
144 |
} |
32465 | 145 |
|
37070 | 146 |
override def iterator: Iterator[A] = make_iterator(rep.start, rep.nexts) |
34304 | 147 |
|
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
148 |
def iterator(elem: A): Iterator[A] = |
37070 | 149 |
if (contains(elem)) make_iterator(Some(elem), rep.nexts) |
150 |
else throw new Linear_Set.Undefined(elem.toString) |
|
151 |
||
37072
9105c8237c7a
renamed "rev" to "reverse" following usual Scala conventions;
wenzelm
parents:
37070
diff
changeset
|
152 |
def reverse_iterator(elem: A): Iterator[A] = |
37070 | 153 |
if (contains(elem)) make_iterator(Some(elem), rep.prevs) |
34304 | 154 |
else throw new Linear_Set.Undefined(elem.toString) |
32465 | 155 |
|
36011
3ff725ac13a4
adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents:
34304
diff
changeset
|
156 |
def + (elem: A): Linear_Set[A] = insert_after(rep.end, elem) |
32465 | 157 |
|
158 |
def - (elem: A): Linear_Set[A] = |
|
159 |
if (!contains(elem)) throw new Linear_Set.Undefined(elem.toString) |
|
160 |
else delete_after(prev(elem)) |
|
32464
5b9731f83569
added linear_set.scala from http://isabelle.in.tum.de/repos/isabelle-jedit/rev/d567692f9717
wenzelm
parents:
diff
changeset
|
161 |
} |