Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
c4526f22
Commit
c4526f22
authored
14 years ago
by
Viktor Kuncak
Browse files
Options
Downloads
Patches
Plain Diff
cosmetic changes
parent
7c153e6e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pldi2011-testcases/RedBlackTree.scala
+7
-11
7 additions, 11 deletions
pldi2011-testcases/RedBlackTree.scala
with
7 additions
and
11 deletions
pldi2011-testcases/RedBlackTree.scala
+
7
−
11
View file @
c4526f22
import
scala.collection.immutable.Set
//import scala.collection.immutable.Multiset
object
RedBlackTree
{
sealed
abstract
class
Color
case
class
Red
()
extends
Color
...
...
@@ -26,10 +24,13 @@ object RedBlackTree {
if
(
x
<
y
)
balance
(
c
,
ins
(
x
,
a
),
y
,
b
)
else
if
(
x
==
y
)
Node
(
c
,
a
,
y
,
b
)
else
balance
(
c
,
a
,
y
,
ins
(
x
,
b
))
})
ensuring
(
res
=>
(
content
(
res
)
==
content
(
t
)
++
Set
(
x
)
// && size(t) <= size(res) && size(res) < size(t) + 2)
))
})
ensuring
(
res
=>
content
(
res
)
==
content
(
t
)
++
Set
(
x
)
&&
size
(
t
)
<=
size
(
res
)
&&
size
(
res
)
<=
size
(
t
)
+
1
)
def
makeBlack
(
n
:
Tree
)
:
Tree
=
n
match
{
case
Node
(
Red
(),
l
,
v
,
r
)
=>
Node
(
Black
(),
l
,
v
,
r
)
case
_
=>
n
}
def
add
(
x
:
Int
,
t
:
Tree
)
:
Tree
=
{
makeBlack
(
ins
(
x
,
t
))
...
...
@@ -46,9 +47,4 @@ object RedBlackTree {
Node
(
Red
(),
Node
(
Black
(),
a
,
xV
,
b
),
yV
,
Node
(
Black
(),
c
,
zV
,
d
))
case
Node
(
c
,
a
,
xV
,
b
)
=>
Node
(
c
,
a
,
xV
,
b
)
})
ensuring
(
res
=>
content
(
res
)
==
content
(
Node
(
c
,
a
,
x
,
b
)))
def
makeBlack
(
n
:
Tree
)
:
Tree
=
n
match
{
case
Node
(
Red
(),
l
,
v
,
r
)
=>
Node
(
Black
(),
l
,
v
,
r
)
case
_
=>
n
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment