annotate src/AgdaTree.agda @ 3:b124f02ea3f1

post agda code
author soto@cr.ie.u-ryukyu.ac.jp
date Wed, 09 Sep 2020 22:07:32 +0900
parents 73127e0ab57c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
1 record TreeMethods {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.⊔ n) where
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
2 field
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
3 putImpl : treeImpl -> a -> (treeImpl -> t) -> t
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
4 getImpl : treeImpl -> (treeImpl -> Maybe a -> t) -> t
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
5 open TreeMethods
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
6
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
7 record Tree {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.⊔ n) where
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
8 field
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
9 tree : treeImpl
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
10 treeMethods : TreeMethods {n} {m} {a} {t} treeImpl
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
11 putTree : a -> (Tree treeImpl -> t) -> t
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
12 putTree d next = putImpl (treeMethods ) tree d (\t1 -> next (record {tree = t1 ; treeMethods = treeMethods} ))
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
13 getTree : (Tree treeImpl -> Maybe a -> t) -> t
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
14 getTree next = getImpl (treeMethods ) tree (\t1 d -> next (record {tree = t1 ; treeMethods = treeMethods} ) d )
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
15 open Tree
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
16
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
17 record RedBlackTree {n m : Level } {t : Set m} (a k : Set n) : Set (m Level.⊔ n) where
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
18 field
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
19 root : Maybe (Node a k)
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
20 nodeStack : SingleLinkedStack (Node a k)
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
21 compare : k -> k -> CompareResult {n}
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
22 open RedBlackTree