Skip to content

Commit aca7f9c

Browse files
wkrozowskiTwoFX
andauthored
feat: add DTreeMap/TreeMap/TreeSet iterators and slices (#10776)
This PR adds iterators and slices for `DTreeMap`/`TreeMap`/`TreeSet` based on zippers and provides basic lemmas about them. --------- Co-authored-by: Markus Himmel <[email protected]>
1 parent aaceb3d commit aca7f9c

File tree

21 files changed

+3031
-1
lines changed

21 files changed

+3031
-1
lines changed

src/Std/Data/DTreeMap.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ prelude
99
public import Std.Data.DTreeMap.Basic
1010
public import Std.Data.DTreeMap.AdditionalOperations
1111
public import Std.Data.DTreeMap.Lemmas
12+
public import Std.Data.DTreeMap.Iterator
13+
public import Std.Data.DTreeMap.Slice

src/Std/Data/DTreeMap/Internal/Def.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,11 @@ def toListModel : Impl α β → List ((a : α) × β a)
7878
@[simp] theorem toListModel_inner {sz k v l r} :
7979
(.inner sz k v l r : Impl α β).toListModel = l.toListModel ++ ⟨k, v⟩ :: r.toListModel := rfl
8080

81+
/--
82+
Computes the size of the tree. Used for verification of iterators.
83+
-/
84+
def treeSize : Internal.Impl α β → Nat
85+
| .leaf => 0
86+
| .inner _ _ _ l r => 1 + l.treeSize + treeSize r
87+
8188
end Std.DTreeMap.Internal.Impl

0 commit comments

Comments
 (0)