comparison paper/src/AgdaTree.agda @ 3:959f4b34d6f4

add final thesis
author soto
date Tue, 09 Feb 2021 18:44:53 +0900
parents
children
comparison
equal deleted inserted replaced
2:2c50fd1d115e 3:959f4b34d6f4
1 record TreeMethods {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.⊔ n) where
2 field
3 putImpl : treeImpl -> a -> (treeImpl -> t) -> t
4 getImpl : treeImpl -> (treeImpl -> Maybe a -> t) -> t
5 open TreeMethods
6
7 record Tree {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.⊔ n) where
8 field
9 tree : treeImpl
10 treeMethods : TreeMethods {n} {m} {a} {t} treeImpl
11 putTree : a -> (Tree treeImpl -> t) -> t
12 putTree d next = putImpl (treeMethods ) tree d (\t1 -> next (record {tree = t1 ; treeMethods = treeMethods} ))
13 getTree : (Tree treeImpl -> Maybe a -> t) -> t
14 getTree next = getImpl (treeMethods ) tree (\t1 d -> next (record {tree = t1 ; treeMethods = treeMethods} ) d )
15 open Tree
16
17 record RedBlackTree {n m : Level } {t : Set m} (a k : Set n) : Set (m Level.⊔ n) where
18 field
19 root : Maybe (Node a k)
20 nodeStack : SingleLinkedStack (Node a k)
21 compare : k -> k -> CompareResult {n}
22 open RedBlackTree