Documentation

Batteries.Data.RBMap.Basic

Red-black trees #

Note: users are recommended to use Std.TreeMap instead of Batteries.RBMap. Std.TreeMap is a mostly drop-in replacement (notably, there is no ToStream instance yet), and has more complete and consistent API. This implementation will eventually be deprecated.

This module implements a type RBMap α β cmp which is a functional data structure for storing a key-value store in a binary search tree.

It is built on the simpler RBSet α cmp type, which stores a set of values of type α using the function cmp : α → α → Ordering for determining the ordering relation. The tree will never store two elements that compare .eq under the cmp function, but the function does not have to satisfy cmp x y = .eq → x = y, and in the map case α is a key-value pair and the cmp function only compares the keys.

In a red-black tree, every node has a color which is either "red" or "black" (this particular choice of colors is conventional). A nil node is considered black.

  • red : RBColor

    A red node is required to have black children.

  • black : RBColor

    Every path from the root to a leaf must pass through the same number of black nodes.

Instances For
    @[implicit_reducible]
    inductive Batteries.RBNode (α : Type u) :

    A red-black tree. (This is an internal implementation detail of the RBSet type, which includes the invariants of the tree.) This is a binary search tree augmented with a "color" field which is either red or black for each node and used to implement the re-balancing operations. See: Red–black tree

    • nil {α : Type u} : RBNode α

      An empty tree.

    • node {α : Type u} (c : RBColor) (l : RBNode α) (v : α) (r : RBNode α) : RBNode α

      A node consists of a value v, a subtree l of smaller items, and a subtree r of larger items. The color c is either red or black and participates in the red-black balance invariant (see Balanced).

    Instances For
      @[implicit_reducible]
      instance Batteries.instReprRBNode {α✝ : Type u_1} [Repr α✝] :
      Repr (RBNode α✝)
      def Batteries.instReprRBNode.repr {α✝ : Type u_1} [Repr α✝] :
      RBNode α✝ → Nat → Std.Format
      Instances For
        @[implicit_reducible]
        def Batteries.RBNode.min? {α : Type u_1} :
        RBNode α → Option α

        The minimum element of a tree is the left-most value.

        Instances For
          def Batteries.RBNode.max? {α : Type u_1} :
          RBNode α → Option α

          The maximum element of a tree is the right-most value.

          Instances For
            @[specialize #[]]
            def Batteries.RBNode.fold {σ : Sort u_1} {α : Type u_2} (v₀ : σ) (f : σ → α → σ → σ) :
            RBNode α → σ

            Fold a function in tree order along the nodes. v₀ is used at nil nodes and f is used to combine results at branching nodes.

            Instances For
              @[specialize #[]]
              def Batteries.RBNode.foldl {σ : Sort u_1} {α : Type u_2} (f : σ → α → σ) (init : σ) :
              RBNode α → σ

              Fold a function on the values from left to right (in increasing order).

              Instances For
                @[specialize #[]]
                def Batteries.RBNode.foldr {α : Type u_1} {σ : Sort u_2} (f : α → σ → σ) :
                RBNode α → (init : σ) → σ

                Fold a function on the values from right to left (in decreasing order).

                Instances For
                  def Batteries.RBNode.toList {α : Type u_1} (t : RBNode α) :
                  List α

                  O(n). Convert the tree to a list in ascending order.

                  Instances For
                    @[specialize #[]]
                    def Batteries.RBNode.forM {m : Type u_1 → Type u_2} {α : Type u_3} [Monad m] (f : α → m PUnit) :
                    RBNode α → m PUnit

                    Run monadic function f on each element of the tree (in increasing order).

                    Instances For
                      @[specialize #[]]
                      def Batteries.RBNode.foldlM {m : Type u_1 → Type u_2} {σ : Type u_1} {α : Type u_3} [Monad m] (f : σ → α → m σ) (init : σ) :
                      RBNode α → m σ

                      Fold a monadic function on the values from left to right (in increasing order).

                      Instances For
                        @[inline]
                        def Batteries.RBNode.forIn {m : Type u_1 → Type u_2} {α : Type u_3} {σ : Type u_1} [Monad m] (as : RBNode α) (init : σ) (f : α → σ → m (ForInStep σ)) :
                        m σ

                        Implementation of for x in t loops over a RBNode (in increasing order).

                        Instances For
                          @[specialize #[]]
                          def Batteries.RBNode.forIn.visit {m : Type u_1 → Type u_2} {α : Type u_3} {σ : Type u_1} [Monad m] (f : α → σ → m (ForInStep σ)) :
                          RBNode α → σ → m (ForInStep σ)

                          Inner loop of forIn.

                          Instances For
                            @[implicit_reducible]
                            instance Batteries.RBNode.instForInOfMonad {m : Type u_1 → Type u_2} {α : Type u_3} [Monad m] :
                            ForIn m (RBNode α) α
                            inductive Batteries.RBNode.Stream (α : Type u_1) :
                            Type u_1

                            An auxiliary data structure (an iterator) over an RBNode which lazily pulls elements from the left.

                            • nil {α : Type u_1} : RBNode.Stream α

                              The stream is empty.

                            • cons {α : Type u_1} (v : α) (r : RBNode α) (tail : RBNode.Stream α) : RBNode.Stream α

                              We are ready to deliver element v with right child r, and where tail represents all the subtrees we have yet to destructure.

                            Instances For

                              O(log n). Turn a node into a stream, by descending along the left spine.

                              Instances For

                                O(1) amortized, O(log n) worst case: Get the next element from the stream.

                                Instances For
                                  @[specialize #[]]
                                  def Batteries.RBNode.Stream.foldl {σ : Sort u_1} {α : Type u_2} (f : σ → α → σ) (init : σ) :
                                  RBNode.Stream α → σ

                                  Fold a function on the values from left to right (in increasing order).

                                  Instances For
                                    @[specialize #[]]
                                    def Batteries.RBNode.Stream.foldr {α : Type u_1} {σ : Sort u_2} (f : α → σ → σ) :
                                    RBNode.Stream α → (init : σ) → σ

                                    Fold a function on the values from right to left (in decreasing order).

                                    Instances For

                                      O(n). Convert the stream to a list in ascending order.

                                      Instances For
                                        @[implicit_reducible]
                                        @[implicit_reducible]
                                        @[specialize #[]]
                                        def Batteries.RBNode.all {α : Type u_1} (p : α → Bool) :
                                        RBNode α → Bool

                                        Returns true iff every element of the tree satisfies p.

                                        Instances For
                                          @[specialize #[]]
                                          def Batteries.RBNode.any {α : Type u_1} (p : α → Bool) :
                                          RBNode α → Bool

                                          Returns true iff any element of the tree satisfies p.

                                          Instances For
                                            def Batteries.RBNode.All {α : Type u_1} (p : α → Prop) :
                                            RBNode α → Prop

                                            Asserts that p holds on every element of the tree.

                                            Instances For
                                              theorem Batteries.RBNode.All.imp {α : Type u_1} {p q : α → Prop} (H : ∀ {x : α}, p x → q x) {t : RBNode α} :
                                              All p t → All q t
                                              theorem Batteries.RBNode.all_iff {α : Type u_1} {p : α → Bool} {t : RBNode α} :
                                              all p t = true ↔ All (fun (x : α) => p x = true) t
                                              @[implicit_reducible]
                                              instance Batteries.RBNode.instDecidableAllOfDecidablePred {α : Type u_1} {p : α → Prop} {t : RBNode α} [DecidablePred p] :
                                              def Batteries.RBNode.Any {α : Type u_1} (p : α → Prop) :
                                              RBNode α → Prop

                                              Asserts that p holds on some element of the tree.

                                              Instances For
                                                theorem Batteries.RBNode.any_iff {α : Type u_1} {p : α → Bool} {t : RBNode α} :
                                                any p t = true ↔ Any (fun (x : α) => p x = true) t
                                                @[implicit_reducible]
                                                instance Batteries.RBNode.instDecidableAnyOfDecidablePred {α : Type u_1} {p : α → Prop} {t : RBNode α} [DecidablePred p] :
                                                def Batteries.RBNode.EMem {α : Type u_1} (x : α) (t : RBNode α) :

                                                True if x is an element of t "exactly", i.e. up to equality, not the cmp relation.

                                                Instances For
                                                  @[implicit_reducible]
                                                  def Batteries.RBNode.MemP {α : Type u_1} (cut : α → Ordering) (t : RBNode α) :

                                                  True if the specified cut matches at least one element of of t.

                                                  Instances For
                                                    @[reducible]
                                                    def Batteries.RBNode.Mem {α : Type u_1} (cmp : α → α → Ordering) (x : α) (t : RBNode α) :

                                                    True if x is equivalent to an element of t.

                                                    Instances For
                                                      @[implicit_reducible]
                                                      def Batteries.RBNode.Slow.instDecidableEMem {α : Type u_1} {x : α} [DecidableEq α] {t : RBNode α} :
                                                      Instances For
                                                        @[implicit_reducible]
                                                        def Batteries.RBNode.Slow.instDecidableMemP {α : Type u_1} {cut : α → Ordering} {t : RBNode α} :
                                                        Decidable (MemP cut t)
                                                        Instances For
                                                          @[implicit_reducible]
                                                          def Batteries.RBNode.Slow.instDecidableMem {α : Type u_1} {cmp : α → α → Ordering} {x : α} {t : RBNode α} :
                                                          Decidable (Mem cmp x t)
                                                          Instances For
                                                            @[specialize #[]]
                                                            def Batteries.RBNode.all₂ {α : Type u_1} {β : Type u_2} (R : α → β → Bool) (t₁ : RBNode α) (t₂ : RBNode β) :

                                                            Asserts that t₁ and t₂ have the same number of elements in the same order, and R holds pairwise between them. The tree structure is ignored.

                                                            Instances For
                                                              @[implicit_reducible]
                                                              instance Batteries.RBNode.instBEq {α : Type u_1} [BEq α] :
                                                              BEq (RBNode α)
                                                              def Batteries.RBNode.cmpLT {α : Type u_1} (cmp : α → α → Ordering) (x y : α) :

                                                              We say that x < y under the comparator cmp if cmp x y = .lt.

                                                              • In order to avoid assuming the comparator is always lawful, we use a local ∀ [Std.TransCmp cmp] binder in the relation so that the ordering properties of the tree only need to hold if the comparator is lawful.
                                                              • The Nonempty wrapper is a no-op because this is already a proposition, but it prevents the [Std.TransCmp cmp] binder from being introduced when we don't want it.
                                                              Instances For
                                                                theorem Batteries.RBNode.cmpLT_iff {α✝ : Type u_1} {cmp : α✝ → α✝ → Ordering} {x y : α✝} [Std.TransCmp cmp] :
                                                                cmpLT cmp x y ↔ cmp x y = Ordering.lt
                                                                @[implicit_reducible]
                                                                instance Batteries.RBNode.instDecidableCmpLTOfTransCmp {α✝ : Type u_1} {x y : α✝} (cmp : α✝ → α✝ → Ordering) [Std.TransCmp cmp] :
                                                                Decidable (cmpLT cmp x y)
                                                                def Batteries.RBNode.cmpEq {α : Type u_1} (cmp : α → α → Ordering) (x y : α) :

                                                                We say that x ≈ y under the comparator cmp if cmp x y = .eq. See also cmpLT.

                                                                Instances For
                                                                  theorem Batteries.RBNode.cmpEq_iff {α✝ : Type u_1} {cmp : α✝ → α✝ → Ordering} {x y : α✝} [Std.TransCmp cmp] :
                                                                  cmpEq cmp x y ↔ cmp x y = Ordering.eq
                                                                  @[implicit_reducible]
                                                                  instance Batteries.RBNode.instDecidableCmpEqOfTransCmp {α✝ : Type u_1} {x y : α✝} (cmp : α✝ → α✝ → Ordering) [Std.TransCmp cmp] :
                                                                  Decidable (cmpEq cmp x y)
                                                                  def Batteries.RBNode.isOrdered {α : Type u_1} (cmp : α → α → Ordering) (t : RBNode α) (l r : Option α := none) :

                                                                  O(n). Verifies an ordering relation on the nodes of the tree.

                                                                  Instances For
                                                                    @[inline]
                                                                    def Batteries.RBNode.balance1 {α : Type u_1} :
                                                                    RBNode α → α → RBNode α → RBNode α

                                                                    The first half of Okasaki's balance, concerning red-red sequences in the left child.

                                                                    Instances For
                                                                      @[inline]
                                                                      def Batteries.RBNode.balance2 {α : Type u_1} :
                                                                      RBNode α → α → RBNode α → RBNode α

                                                                      The second half of Okasaki's balance, concerning red-red sequences in the right child.

                                                                      Instances For
                                                                        @[inline]
                                                                        def Batteries.RBNode.isRed {α : Type u_1} :

                                                                        Returns red if the node is red, otherwise black. (Nil nodes are treated as black.)

                                                                        Instances For
                                                                          @[inline]

                                                                          Returns black if the node is black, otherwise red. (Nil nodes are treated as red, which is not the usual convention but useful for deletion.)

                                                                          Instances For
                                                                            def Batteries.RBNode.setBlack {α : Type u_1} :
                                                                            RBNode α → RBNode α

                                                                            Changes the color of the root to black.

                                                                            Instances For
                                                                              def Batteries.RBNode.reverse {α : Type u_1} :
                                                                              RBNode α → RBNode α

                                                                              O(n). Reverses the ordering of the tree without any rebalancing.

                                                                              Instances For
                                                                                @[specialize #[]]
                                                                                def Batteries.RBNode.ins {α : Type u_1} (cmp : α → α → Ordering) (x : α) :
                                                                                RBNode α → RBNode α

                                                                                The core of the insert function. This adds an element x to a balanced red-black tree. Importantly, the result of calling ins is not a proper red-black tree, because it has a broken balance invariant. (See Balanced.ins for the balance invariant of ins.) The insert function does the final fixup needed to restore the invariant.

                                                                                Instances For
                                                                                  @[specialize #[]]
                                                                                  def Batteries.RBNode.insert {α : Type u_1} (cmp : α → α → Ordering) (t : RBNode α) (v : α) :

                                                                                  insert cmp t v inserts element v into the tree, using the provided comparator cmp to put it in the right place and automatically rebalancing the tree as necessary.

                                                                                  Instances For
                                                                                    def Batteries.RBNode.setRed {α : Type u_1} :
                                                                                    RBNode α → RBNode α

                                                                                    Recolor the root of the tree to red if possible.

                                                                                    Instances For
                                                                                      def Batteries.RBNode.balLeft {α : Type u_1} (l : RBNode α) (v : α) (r : RBNode α) :

                                                                                      Rebalancing a tree which has shrunk on the left.

                                                                                      Instances For
                                                                                        def Batteries.RBNode.balRight {α : Type u_1} (l : RBNode α) (v : α) (r : RBNode α) :

                                                                                        Rebalancing a tree which has shrunk on the right.

                                                                                        Instances For
                                                                                          def Batteries.RBNode.size {α : Type u_1} :
                                                                                          RBNode α → Nat

                                                                                          The number of nodes in the tree.

                                                                                          Instances For
                                                                                            @[irreducible]
                                                                                            def Batteries.RBNode.append {α : Type u_1} :
                                                                                            RBNode α → RBNode α → RBNode α

                                                                                            Concatenate two trees with the same black-height.

                                                                                            Instances For

                                                                                              erase #

                                                                                              @[specialize #[]]
                                                                                              def Batteries.RBNode.del {α : Type u_1} (cut : α → Ordering) :
                                                                                              RBNode α → RBNode α

                                                                                              The core of the erase function. The tree returned from this function has a broken invariant, which is restored in erase.

                                                                                              Instances For
                                                                                                @[specialize #[]]
                                                                                                def Batteries.RBNode.erase {α : Type u_1} (cut : α → Ordering) (t : RBNode α) :

                                                                                                The erase cut t function removes an element from the tree t. The cut function is used to locate an element in the tree: it returns .gt if we go too high and .lt if we go too low; if it returns .eq we will remove the element. (The function cmp k for some key k is a valid cut function, but we can also use cuts that are not of this form as long as they are suitably monotonic.)

                                                                                                Instances For
                                                                                                  @[specialize #[]]
                                                                                                  def Batteries.RBNode.find? {α : Type u_1} (cut : α → Ordering) :
                                                                                                  RBNode α → Option α

                                                                                                  Finds an element in the tree satisfying the cut function.

                                                                                                  Instances For
                                                                                                    @[specialize #[]]
                                                                                                    def Batteries.RBNode.upperBound? {α : Type u_1} (cut : α → Ordering) :
                                                                                                    RBNode α → (ub : optParam (Option α) none) → Option α

                                                                                                    upperBound? cut retrieves the smallest entry larger than or equal to cut, if it exists.

                                                                                                    Instances For
                                                                                                      @[specialize #[]]
                                                                                                      def Batteries.RBNode.lowerBound? {α : Type u_1} (cut : α → Ordering) :
                                                                                                      RBNode α → (lb : optParam (Option α) none) → Option α

                                                                                                      lowerBound? cut retrieves the largest entry smaller than or equal to cut, if it exists.

                                                                                                      Instances For
                                                                                                        def Batteries.RBNode.root? {α : Type u_1} :
                                                                                                        RBNode α → Option α

                                                                                                        Returns the root of the tree, if any.

                                                                                                        Instances For
                                                                                                          @[specialize #[]]
                                                                                                          def Batteries.RBNode.map {α : Type u_1} {β : Type u_2} (f : α → β) :
                                                                                                          RBNode α → RBNode β

                                                                                                          O(n). Map a function on every value in the tree. This requires IsMonotone on the function in order to preserve the order invariant.

                                                                                                          Instances For
                                                                                                            def Batteries.RBNode.toArray {α : Type u_1} (n : RBNode α) :

                                                                                                            Converts the tree into an array in increasing sorted order.

                                                                                                            Instances For
                                                                                                              inductive Batteries.RBNode.Path (α : Type u) :

                                                                                                              A RBNode.Path α is a "cursor" into an RBNode which represents the path from the root to a subtree. Note that the path goes from the target subtree up to the root, which is reversed from the normal way data is stored in the tree. See Zipper for more information.

                                                                                                              • root {α : Type u} : Path α

                                                                                                                The root of the tree, which is the end of the path of parents.

                                                                                                              • left {α : Type u} (c : RBColor) (parent : Path α) (v : α) (r : RBNode α) : Path α

                                                                                                                A path that goes down the left subtree.

                                                                                                              • right {α : Type u} (c : RBColor) (l : RBNode α) (v : α) (parent : Path α) : Path α

                                                                                                                A path that goes down the right subtree.

                                                                                                              Instances For
                                                                                                                def Batteries.RBNode.Path.fill {α : Type u_1} :
                                                                                                                Path α → RBNode α → RBNode α

                                                                                                                Fills the Path with a subtree.

                                                                                                                Instances For
                                                                                                                  @[specialize #[]]
                                                                                                                  def Batteries.RBNode.zoom {α : Type u_1} (cut : α → Ordering) :
                                                                                                                  RBNode α → (e : optParam (Path α) Path.root) → RBNode α × Path α

                                                                                                                  Like find?, but instead of just returning the element, it returns the entire subtree at the element and a path back to the root for reconstructing the tree.

                                                                                                                  Instances For
                                                                                                                    def Batteries.RBNode.Path.ins {α : Type u_1} :
                                                                                                                    Path α → RBNode α → RBNode α

                                                                                                                    This function does the second part of RBNode.ins, which unwinds the stack and rebuilds the tree.

                                                                                                                    Instances For
                                                                                                                      @[inline]
                                                                                                                      def Batteries.RBNode.Path.insertNew {α : Type u_1} (path : Path α) (v : α) :

                                                                                                                      path.insertNew v inserts element v into the tree, assuming that path is zoomed in on a nil node such that inserting a new element at this position is valid.

                                                                                                                      Instances For
                                                                                                                        def Batteries.RBNode.Path.insert {α : Type u_1} (path : Path α) (t : RBNode α) (v : α) :

                                                                                                                        path.insert t v inserts element v into the tree, assuming that (t, path) was the result of a previous zoom operation (so either the root of t is equivalent to v or it is empty).

                                                                                                                        Instances For
                                                                                                                          def Batteries.RBNode.Path.del {α : Type u_1} :
                                                                                                                          Path α → RBNode α → RBColor → RBNode α

                                                                                                                          path.del t c does the second part of RBNode.del, which unwinds the stack and rebuilds the tree. The c argument is the color of the node before the deletion (we used t₀.isBlack for this in RBNode.del but the original tree is no longer available in this formulation).

                                                                                                                          Instances For
                                                                                                                            def Batteries.RBNode.Path.erase {α : Type u_1} (path : Path α) (t : RBNode α) :

                                                                                                                            path.erase t v removes the root element of t from the tree, assuming that (t, path) was the result of a previous zoom operation.

                                                                                                                            Instances For
                                                                                                                              @[specialize #[]]
                                                                                                                              def Batteries.RBNode.modify {α : Type u_1} (cut : α → Ordering) (f : α → α) (t : RBNode α) :

                                                                                                                              modify cut f t uses cut to find an element, then modifies the element using f and reinserts it into the tree.

                                                                                                                              Because the tree structure is not modified, f must not modify the ordering properties of the element.

                                                                                                                              The element in t is used linearly if t is unshared.

                                                                                                                              Instances For
                                                                                                                                @[specialize #[]]
                                                                                                                                def Batteries.RBNode.alter {α : Type u_1} (cut : α → Ordering) (f : Option α → Option α) (t : RBNode α) :

                                                                                                                                alter cut f t simultaneously handles inserting, erasing and replacing an element using a function f : Option α → Option α. It is passed the result of t.find? cut and can either return none to remove the element or some a to replace/insert the element with a (which must have the same ordering properties as the original element).

                                                                                                                                The element is used linearly if t is unshared.

                                                                                                                                Instances For
                                                                                                                                  def Batteries.RBNode.Ordered {α : Type u_1} (cmp : α → α → Ordering) :
                                                                                                                                  RBNode α → Prop

                                                                                                                                  The ordering invariant of a red-black tree, which is a binary search tree. This says that every element of a left subtree is less than the root, and every element in the right subtree is greater than the root, where the less than relation x < y is understood to mean cmp x y = .lt.

                                                                                                                                  Because we do not assume that cmp is lawful when stating this property, we write it in such a way that if cmp is not lawful then the condition holds trivially. That way we can prove the ordering invariants without assuming cmp is lawful.

                                                                                                                                  Instances For
                                                                                                                                    @[implicit_reducible]
                                                                                                                                    def Batteries.RBNode.Slow.instDecidableOrdered {α : Type u_1} (cmp : α → α → Ordering) [Std.TransCmp cmp] (t : RBNode α) :
                                                                                                                                    Instances For
                                                                                                                                      inductive Batteries.RBNode.Balanced {α : Type u_1} :
                                                                                                                                      RBNode α → RBColor → Nat → Prop

                                                                                                                                      The red-black balance invariant. Balanced t c n says that the color of the root node is c, and the black-height (the number of black nodes on any path from the root) of the tree is n. Additionally, every red node must have black children.

                                                                                                                                      Instances For
                                                                                                                                        inductive Batteries.RBNode.WF {α : Type u_1} (cmp : α → α → Ordering) :
                                                                                                                                        RBNode α → Prop

                                                                                                                                        The well-formedness invariant for a red-black tree. The first constructor is the real invariant, and the others allow us to "cheat" in this file and define insert and erase, which have more complex proofs that are delayed to Batteries.Data.RBMap.Lemmas.

                                                                                                                                        • mk {α : Type u_1} {cmp : α → α → Ordering} {t : RBNode α} {c : RBColor} {n : Nat} : Ordered cmp t → t.Balanced c n → WF cmp t

                                                                                                                                          The actual well-formedness invariant: a red-black tree has the ordering and balance invariants.

                                                                                                                                        • insert {α : Type u_1} {cmp : α → α → Ordering} {t : RBNode α} {a : α} : WF cmp t → WF cmp (RBNode.insert cmp t a)

                                                                                                                                          Inserting into a well-formed tree yields another well-formed tree. (See Ordered.insert and Balanced.insert for the actual proofs.)

                                                                                                                                        • erase {α : Type u_1} {cmp : α → α → Ordering} {t : RBNode α} {cut : α → Ordering} : WF cmp t → WF cmp (RBNode.erase cut t)

                                                                                                                                          Erasing from a well-formed tree yields another well-formed tree. (See Ordered.erase and Balanced.erase for the actual proofs.)

                                                                                                                                        Instances For
                                                                                                                                          def Batteries.RBSet (α : Type u) (cmp : α → α → Ordering) :

                                                                                                                                          An RBSet is a self-balancing binary search tree. The cmp function is the comparator that will be used for performing searches; it should satisfy the requirements of TransCmp for it to have sensible behavior.

                                                                                                                                          Instances For
                                                                                                                                            @[inline]
                                                                                                                                            def Batteries.mkRBSet (α : Type u) (cmp : α → α → Ordering) :
                                                                                                                                            RBSet α cmp

                                                                                                                                            O(1). Construct a new empty tree.

                                                                                                                                            Instances For
                                                                                                                                              @[inline]
                                                                                                                                              def Batteries.RBSet.empty {α : Type u_1} {cmp : α → α → Ordering} :
                                                                                                                                              RBSet α cmp

                                                                                                                                              O(1). Construct a new empty tree.

                                                                                                                                              Instances For
                                                                                                                                                @[implicit_reducible]
                                                                                                                                                instance Batteries.RBSet.instEmptyCollection (α : Type u) (cmp : α → α → Ordering) :
                                                                                                                                                @[implicit_reducible]
                                                                                                                                                instance Batteries.RBSet.instInhabited (α : Type u) (cmp : α → α → Ordering) :
                                                                                                                                                Inhabited (RBSet α cmp)
                                                                                                                                                @[inline]
                                                                                                                                                def Batteries.RBSet.single {α : Type u_1} {cmp : α → α → Ordering} (v : α) :
                                                                                                                                                RBSet α cmp

                                                                                                                                                O(1). Construct a new tree with one element v.

                                                                                                                                                Instances For
                                                                                                                                                  @[inline]
                                                                                                                                                  def Batteries.RBSet.foldl {σ : Sort u_1} {α : Type u_2} {cmp : α → α → Ordering} (f : σ → α → σ) (init : σ) (t : RBSet α cmp) :
                                                                                                                                                  σ

                                                                                                                                                  O(n). Fold a function on the values from left to right (in increasing order).

                                                                                                                                                  Instances For
                                                                                                                                                    @[inline]
                                                                                                                                                    def Batteries.RBSet.foldr {α : Type u_1} {σ : Sort u_2} {cmp : α → α → Ordering} (f : α → σ → σ) (init : σ) (t : RBSet α cmp) :
                                                                                                                                                    σ

                                                                                                                                                    O(n). Fold a function on the values from right to left (in decreasing order).

                                                                                                                                                    Instances For
                                                                                                                                                      @[inline]
                                                                                                                                                      def Batteries.RBSet.foldlM {m : Type u_1 → Type u_2} {σ : Type u_1} {α : Type u_3} {cmp : α → α → Ordering} [Monad m] (f : σ → α → m σ) (init : σ) (t : RBSet α cmp) :
                                                                                                                                                      m σ

                                                                                                                                                      O(n). Fold a monadic function on the values from left to right (in increasing order).

                                                                                                                                                      Instances For
                                                                                                                                                        @[inline]
                                                                                                                                                        def Batteries.RBSet.forM {m : Type u_1 → Type u_2} {α : Type u_3} {cmp : α → α → Ordering} [Monad m] (f : α → m PUnit) (t : RBSet α cmp) :

                                                                                                                                                        O(n). Run monadic function f on each element of the tree (in increasing order).

                                                                                                                                                        Instances For
                                                                                                                                                          @[implicit_reducible]
                                                                                                                                                          instance Batteries.RBSet.instForInOfMonad {m : Type u_1 → Type u_2} {α : Type u_3} {cmp : α → α → Ordering} [Monad m] :
                                                                                                                                                          ForIn m (RBSet α cmp) α
                                                                                                                                                          @[implicit_reducible]
                                                                                                                                                          instance Batteries.RBSet.instToStreamStream {α : Type u_1} {cmp : α → α → Ordering} :
                                                                                                                                                          @[inline]
                                                                                                                                                          def Batteries.RBSet.isEmpty {α : Type u_1} {cmp : α → α → Ordering} :
                                                                                                                                                          RBSet α cmp → Bool

                                                                                                                                                          O(1). Is the tree empty?

                                                                                                                                                          Instances For
                                                                                                                                                            @[inline]
                                                                                                                                                            def Batteries.RBSet.toList {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) :
                                                                                                                                                            List α

                                                                                                                                                            O(n). Convert the tree to a list in ascending order.

                                                                                                                                                            Instances For
                                                                                                                                                              @[inline]
                                                                                                                                                              def Batteries.RBSet.min? {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) :

                                                                                                                                                              O(log n). Returns the entry a such that a ≤ k for all keys in the RBSet.

                                                                                                                                                              Instances For
                                                                                                                                                                @[inline]
                                                                                                                                                                def Batteries.RBSet.max? {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) :

                                                                                                                                                                O(log n). Returns the entry a such that a ≥ k for all keys in the RBSet.

                                                                                                                                                                Instances For
                                                                                                                                                                  @[implicit_reducible]
                                                                                                                                                                  instance Batteries.RBSet.instRepr {α : Type u_1} {cmp : α → α → Ordering} [Repr α] :
                                                                                                                                                                  Repr (RBSet α cmp)
                                                                                                                                                                  @[inline]
                                                                                                                                                                  def Batteries.RBSet.insert {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (v : α) :
                                                                                                                                                                  RBSet α cmp

                                                                                                                                                                  O(log n). Insert element v into the tree.

                                                                                                                                                                  Instances For
                                                                                                                                                                    def Batteries.RBSet.insertMany {ρ : Type u_1} {α : Type u_2} {cmp : α → α → Ordering} [ForIn Id ρ α] (s : RBSet α cmp) (as : ρ) :
                                                                                                                                                                    RBSet α cmp

                                                                                                                                                                    Insert all elements from a collection into a RBSet α cmp.

                                                                                                                                                                    Instances For
                                                                                                                                                                      @[inline]
                                                                                                                                                                      def Batteries.RBSet.erase {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (cut : α → Ordering) :
                                                                                                                                                                      RBSet α cmp

                                                                                                                                                                      O(log n). Remove an element from the tree using a cut function. The cut function is used to locate an element in the tree: it returns .gt if we go too high and .lt if we go too low; if it returns .eq we will remove the element. (The function cmp k for some key k is a valid cut function, but we can also use cuts that are not of this form as long as they are suitably monotonic.)

                                                                                                                                                                      Instances For
                                                                                                                                                                        @[inline]
                                                                                                                                                                        def Batteries.RBSet.findP? {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (cut : α → Ordering) :

                                                                                                                                                                        O(log n). Find an element in the tree using a cut function.

                                                                                                                                                                        Instances For
                                                                                                                                                                          @[inline]
                                                                                                                                                                          def Batteries.RBSet.find? {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (x : α) :

                                                                                                                                                                          O(log n). Returns an element in the tree equivalent to x if one exists.

                                                                                                                                                                          Instances For
                                                                                                                                                                            @[inline]
                                                                                                                                                                            def Batteries.RBSet.findPD {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (cut : α → Ordering) (v₀ : α) :
                                                                                                                                                                            α

                                                                                                                                                                            O(log n). Find an element in the tree, or return a default value v₀.

                                                                                                                                                                            Instances For
                                                                                                                                                                              @[inline]
                                                                                                                                                                              def Batteries.RBSet.upperBoundP? {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (cut : α → Ordering) :

                                                                                                                                                                              O(log n). upperBoundP cut retrieves the smallest entry comparing gt or eq under cut, if it exists. If multiple keys in the map return eq under cut, any of them may be returned.

                                                                                                                                                                              Instances For
                                                                                                                                                                                @[inline]
                                                                                                                                                                                def Batteries.RBSet.upperBound? {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (k : α) :

                                                                                                                                                                                O(log n). upperBound? k retrieves the largest entry smaller than or equal to k, if it exists.

                                                                                                                                                                                Instances For
                                                                                                                                                                                  @[inline]
                                                                                                                                                                                  def Batteries.RBSet.lowerBoundP? {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (cut : α → Ordering) :

                                                                                                                                                                                  O(log n). lowerBoundP cut retrieves the largest entry comparing lt or eq under cut, if it exists. If multiple keys in the map return eq under cut, any of them may be returned.

                                                                                                                                                                                  Instances For
                                                                                                                                                                                    @[inline]
                                                                                                                                                                                    def Batteries.RBSet.lowerBound? {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (k : α) :

                                                                                                                                                                                    O(log n). lowerBound? k retrieves the largest entry smaller than or equal to k, if it exists.

                                                                                                                                                                                    Instances For
                                                                                                                                                                                      @[inline]
                                                                                                                                                                                      def Batteries.RBSet.containsP {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (cut : α → Ordering) :

                                                                                                                                                                                      O(log n). Returns true if the given cut returns eq for something in the RBSet.

                                                                                                                                                                                      Instances For
                                                                                                                                                                                        @[inline]
                                                                                                                                                                                        def Batteries.RBSet.contains {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (a : α) :

                                                                                                                                                                                        O(log n). Returns true if the given key a is in the RBSet.

                                                                                                                                                                                        Instances For
                                                                                                                                                                                          @[inline]
                                                                                                                                                                                          def Batteries.RBSet.ofList {α : Type u_1} (l : List α) (cmp : α → α → Ordering) :
                                                                                                                                                                                          RBSet α cmp

                                                                                                                                                                                          O(n log n). Build a tree from an unsorted list by inserting them one at a time.

                                                                                                                                                                                          Instances For
                                                                                                                                                                                            @[inline]
                                                                                                                                                                                            def Batteries.RBSet.ofArray {α : Type u_1} (l : Array α) (cmp : α → α → Ordering) :
                                                                                                                                                                                            RBSet α cmp

                                                                                                                                                                                            O(n log n). Build a tree from an unsorted array by inserting them one at a time.

                                                                                                                                                                                            Instances For
                                                                                                                                                                                              @[inline]
                                                                                                                                                                                              def Batteries.RBSet.all {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (p : α → Bool) :

                                                                                                                                                                                              O(n). Returns true if the given predicate is true for all items in the RBSet.

                                                                                                                                                                                              Instances For
                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                def Batteries.RBSet.any {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (p : α → Bool) :

                                                                                                                                                                                                O(n). Returns true if the given predicate is true for any item in the RBSet.

                                                                                                                                                                                                Instances For
                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                  def Batteries.RBSet.all₂ {α : Type u_1} {β : Type u_2} {cmpα : α → α → Ordering} {cmpβ : β → β → Ordering} (R : α → β → Bool) (t₁ : RBSet α cmpα) (t₂ : RBSet β cmpβ) :

                                                                                                                                                                                                  Asserts that t₁ and t₂ have the same number of elements in the same order, and R holds pairwise between them. The tree structure is ignored.

                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                    def Batteries.RBSet.EMem {α : Type u_1} {cmp : α → α → Ordering} (x : α) (t : RBSet α cmp) :

                                                                                                                                                                                                    True if x is an element of t "exactly", i.e. up to equality, not the cmp relation.

                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                      def Batteries.RBSet.MemP {α : Type u_1} {cmp : α → α → Ordering} (cut : α → Ordering) (t : RBSet α cmp) :

                                                                                                                                                                                                      True if the specified cut matches at least one element of of t.

                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                        def Batteries.RBSet.Mem {α : Type u_1} {cmp : α → α → Ordering} (x : α) (t : RBSet α cmp) :

                                                                                                                                                                                                        True if x is equivalent to an element of t.

                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                          @[implicit_reducible]
                                                                                                                                                                                                          instance Batteries.RBSet.instMembership {α : Type u_1} {cmp : α → α → Ordering} :
                                                                                                                                                                                                          Membership α (RBSet α cmp)
                                                                                                                                                                                                          @[implicit_reducible]
                                                                                                                                                                                                          def Batteries.RBSet.Slow.instDecidableEMem {α : Type u_1} {cmp : α → α → Ordering} {x : α} [DecidableEq α] {t : RBSet α cmp} :
                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                            @[implicit_reducible]
                                                                                                                                                                                                            def Batteries.RBSet.Slow.instDecidableMemP {α : Type u_1} {cmp : α → α → Ordering} {cut : α → Ordering} {t : RBSet α cmp} :
                                                                                                                                                                                                            Decidable (MemP cut t)
                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                              @[implicit_reducible]
                                                                                                                                                                                                              def Batteries.RBSet.Slow.instDecidableMem {α : Type u_1} {cmp : α → α → Ordering} {x : α} {t : RBSet α cmp} :
                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                @[implicit_reducible]
                                                                                                                                                                                                                instance Batteries.RBSet.instBEq {α : Type u_1} {cmp : α → α → Ordering} [BEq α] :
                                                                                                                                                                                                                BEq (RBSet α cmp)

                                                                                                                                                                                                                Returns true if t₁ and t₂ are equal as sets (assuming cmp and == are compatible), ignoring the internal tree structure.

                                                                                                                                                                                                                def Batteries.RBSet.size {α : Type u_1} {cmp : α → α → Ordering} (m : RBSet α cmp) :

                                                                                                                                                                                                                O(n). The number of items in the RBSet.

                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                  def Batteries.RBSet.min! {α : Type u_1} {cmp : α → α → Ordering} [Inhabited α] (t : RBSet α cmp) :
                                                                                                                                                                                                                  α

                                                                                                                                                                                                                  O(log n). Returns the minimum element of the tree, or panics if the tree is empty.

                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                    def Batteries.RBSet.max! {α : Type u_1} {cmp : α → α → Ordering} [Inhabited α] (t : RBSet α cmp) :
                                                                                                                                                                                                                    α

                                                                                                                                                                                                                    O(log n). Returns the maximum element of the tree, or panics if the tree is empty.

                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                      def Batteries.RBSet.findP! {α : Type u_1} {cmp : α → α → Ordering} [Inhabited α] (t : RBSet α cmp) (cut : α → Ordering) :
                                                                                                                                                                                                                      α

                                                                                                                                                                                                                      O(log n). Attempts to find the value with key k : α in t and panics if there is no such key.

                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                        def Batteries.RBSet.find! {α : Type u_1} {cmp : α → α → Ordering} [Inhabited α] (t : RBSet α cmp) (k : α) :
                                                                                                                                                                                                                        α

                                                                                                                                                                                                                        O(log n). Attempts to find the value with key k : α in t and panics if there is no such key.

                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                          class Batteries.RBSet.ModifyWF {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (cut : α → Ordering) (f : α → α) :

                                                                                                                                                                                                                          The predicate asserting that the result of modifyP is safe to construct.

                                                                                                                                                                                                                          Instances
                                                                                                                                                                                                                            def Batteries.RBSet.modifyP {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (cut : α → Ordering) (f : α → α) [wf : t.ModifyWF cut f] :
                                                                                                                                                                                                                            RBSet α cmp

                                                                                                                                                                                                                            O(log n). In-place replace an element found by cut. This takes the element out of the tree while f runs, so it uses the element linearly if t is unshared.

                                                                                                                                                                                                                            The ModifyWF assumption is required because f may change the ordering properties of the element, which would break the invariants.

                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                              class Batteries.RBSet.AlterWF {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (cut : α → Ordering) (f : Option α → Option α) :

                                                                                                                                                                                                                              The predicate asserting that the result of alterP is safe to construct.

                                                                                                                                                                                                                              Instances
                                                                                                                                                                                                                                def Batteries.RBSet.alterP {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (cut : α → Ordering) (f : Option α → Option α) [wf : t.AlterWF cut f] :
                                                                                                                                                                                                                                RBSet α cmp

                                                                                                                                                                                                                                O(log n). alterP cut f t simultaneously handles inserting, erasing and replacing an element using a function f : Option α → Option α. It is passed the result of t.findP? cut and can either return none to remove the element or some a to replace/insert the element with a (which must have the same ordering properties as the original element).

                                                                                                                                                                                                                                The element is used linearly if t is unshared.

                                                                                                                                                                                                                                The AlterWF assumption is required because f may change the ordering properties of the element, which would break the invariants.

                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                  def Batteries.RBSet.union {α : Type u_1} {cmp : α → α → Ordering} (t₁ t₂ : RBSet α cmp) :
                                                                                                                                                                                                                                  RBSet α cmp

                                                                                                                                                                                                                                  O(n₂ * log (n₁ + n₂)). Merges the maps t₁ and t₂. If equal keys exist in both, the key from t₂ is preferred.

                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                    @[implicit_reducible]
                                                                                                                                                                                                                                    instance Batteries.RBSet.instUnion {α : Type u_1} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                    Union (RBSet α cmp)
                                                                                                                                                                                                                                    def Batteries.RBSet.mergeWith {α : Type u_1} {cmp : α → α → Ordering} (mergeFn : α → α → α) (t₁ t₂ : RBSet α cmp) :
                                                                                                                                                                                                                                    RBSet α cmp

                                                                                                                                                                                                                                    O(n₂ * log (n₁ + n₂)). Merges the maps t₁ and t₂. If equal keys exist in both, then use mergeFn a₁ a₂ to produce the new merged value.

                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                      def Batteries.RBSet.intersectWith {α : Type u_1} {β : Type u_2} {γ : Type u_3} {cmpα : α → α → Ordering} {cmpβ : β → β → Ordering} {cmpγ : γ → γ → Ordering} (cmp : α → β → Ordering) (mergeFn : α → β → γ) (t₁ : RBSet α cmpα) (t₂ : RBSet β cmpβ) :
                                                                                                                                                                                                                                      RBSet γ cmpγ

                                                                                                                                                                                                                                      O(n₁ * log (n₁ + n₂)). Intersects the maps t₁ and t₂ using mergeFn a b to produce the new value.

                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                        def Batteries.RBSet.filter {α : Type u_1} {cmp : α → α → Ordering} (t : RBSet α cmp) (p : α → Bool) :
                                                                                                                                                                                                                                        RBSet α cmp

                                                                                                                                                                                                                                        O(n * log n). Constructs the set of all elements satisfying p.

                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                          def Batteries.RBSet.map {α : Type u_1} {cmpα : α → α → Ordering} {β : Type u_2} {cmpβ : β → β → Ordering} (t : RBSet α cmpα) (f : α → β) :
                                                                                                                                                                                                                                          RBSet β cmpβ

                                                                                                                                                                                                                                          O(n * log n). Map a function on every value in the set. If the function is monotone, consider using the more efficient RBSet.mapMonotone instead.

                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                            def Batteries.RBSet.sdiff {α : Type u_1} {cmp : α → α → Ordering} (t₁ t₂ : RBSet α cmp) :
                                                                                                                                                                                                                                            RBSet α cmp

                                                                                                                                                                                                                                            O(n₁ * (log n₁ + log n₂)). Constructs the set of all elements of t₁ that are not in t₂.

                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                              @[implicit_reducible]
                                                                                                                                                                                                                                              instance Batteries.RBSet.instSDiff {α : Type u_1} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                              SDiff (RBSet α cmp)
                                                                                                                                                                                                                                              def Batteries.RBMap (α : Type u) (β : Type v) (cmp : α → α → Ordering) :
                                                                                                                                                                                                                                              Type (max u v)

                                                                                                                                                                                                                                              An RBMap is a self-balancing binary search tree, used to store a key-value map. The cmp function is the comparator that will be used for performing searches; it should satisfy the requirements of TransCmp for it to have sensible behavior.

                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                def Batteries.mkRBMap (α : Type u) (β : Type v) (cmp : α → α → Ordering) :
                                                                                                                                                                                                                                                RBMap α β cmp

                                                                                                                                                                                                                                                O(1). Construct a new empty map.

                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                  def Batteries.RBMap.empty {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                  RBMap α β cmp

                                                                                                                                                                                                                                                  O(1). Construct a new empty map.

                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                    @[implicit_reducible]
                                                                                                                                                                                                                                                    instance Batteries.instEmptyCollectionRBMap (α : Type u) (β : Type v) (cmp : α → α → Ordering) :
                                                                                                                                                                                                                                                    @[implicit_reducible]
                                                                                                                                                                                                                                                    instance Batteries.instInhabitedRBMap (α : Type u) (β : Type v) (cmp : α → α → Ordering) :
                                                                                                                                                                                                                                                    Inhabited (RBMap α β cmp)
                                                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                                                    def Batteries.RBMap.single {α : Type u_1} {β : Type u_2} {cmp : α → α → Ordering} (k : α) (v : β) :
                                                                                                                                                                                                                                                    RBMap α β cmp

                                                                                                                                                                                                                                                    O(1). Construct a new tree with one key-value pair k, v.

                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                      def Batteries.RBMap.foldl {α : Type u} {β : Type v} {σ : Type w} {cmp : α → α → Ordering} (f : σ → α → β → σ) (init : σ) :
                                                                                                                                                                                                                                                      RBMap α β cmp → σ

                                                                                                                                                                                                                                                      O(n). Fold a function on the values from left to right (in increasing order).

                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                                        def Batteries.RBMap.foldr {α : Type u} {β : Type v} {σ : Type w} {cmp : α → α → Ordering} (f : α → β → σ → σ) (init : σ) :
                                                                                                                                                                                                                                                        RBMap α β cmp → σ

                                                                                                                                                                                                                                                        O(n). Fold a function on the values from right to left (in decreasing order).

                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                          @[inline]
                                                                                                                                                                                                                                                          def Batteries.RBMap.foldlM {α : Type u} {β : Type v} {σ : Type w} {cmp : α → α → Ordering} {m : Type w → Type u_1} [Monad m] (f : σ → α → β → m σ) (init : σ) :
                                                                                                                                                                                                                                                          RBMap α β cmp → m σ

                                                                                                                                                                                                                                                          O(n). Fold a monadic function on the values from left to right (in increasing order).

                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                            @[inline]
                                                                                                                                                                                                                                                            def Batteries.RBMap.forM {α : Type u} {β : Type v} {cmp : α → α → Ordering} {m : Type u_1 → Type u_2} [Monad m] (f : α → β → m PUnit) (t : RBMap α β cmp) :

                                                                                                                                                                                                                                                            O(n). Run monadic function f on each element of the tree (in increasing order).

                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                              @[implicit_reducible]
                                                                                                                                                                                                                                                              instance Batteries.RBMap.instForInProdOfMonad {α : Type u} {β : Type v} {cmp : α → α → Ordering} {m : Type u_1 → Type u_2} [Monad m] :
                                                                                                                                                                                                                                                              ForIn m (RBMap α β cmp) (α × β)
                                                                                                                                                                                                                                                              @[implicit_reducible]
                                                                                                                                                                                                                                                              instance Batteries.RBMap.instToStreamStreamProd {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                              Std.ToStream (RBMap α β cmp) (RBNode.Stream (α × β))
                                                                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                                                                              def Batteries.RBMap.keysArray {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) :

                                                                                                                                                                                                                                                              O(n). Constructs the array of keys of the map.

                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                                def Batteries.RBMap.keysList {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) :
                                                                                                                                                                                                                                                                List α

                                                                                                                                                                                                                                                                O(n). Constructs the list of keys of the map.

                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                  def Batteries.RBMap.Keys (α : Type u_1) (β : Type u_2) (cmp : α → α → Ordering) :
                                                                                                                                                                                                                                                                  Type (max u_1 u_2)

                                                                                                                                                                                                                                                                  An "iterator" over the keys of the map. This is a trivial wrapper over the underlying map, but it comes with a small API to use it in a for loop or convert it to an array or list.

                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                                                                    def Batteries.RBMap.keys {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) :
                                                                                                                                                                                                                                                                    Keys α β cmp

                                                                                                                                                                                                                                                                    The keys of the map. This is an O(1) wrapper operation, which can be used in for loops or converted to an array or list.

                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                                      def Batteries.RBMap.Keys.toArray {α : Type u_1} {β : Type u_2} {cmp : α → α → Ordering} (t : RBMap α β cmp) :

                                                                                                                                                                                                                                                                      O(n). Constructs the array of keys of the map.

                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                                                        def Batteries.RBMap.Keys.toList {α : Type u_1} {β : Type u_2} {cmp : α → α → Ordering} (t : RBMap α β cmp) :
                                                                                                                                                                                                                                                                        List α

                                                                                                                                                                                                                                                                        O(n). Constructs the list of keys of the map.

                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                          @[implicit_reducible]
                                                                                                                                                                                                                                                                          instance Batteries.RBMap.instCoeHeadKeysArray {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                                          CoeHead (Keys α β cmp) (Array α)
                                                                                                                                                                                                                                                                          @[implicit_reducible]
                                                                                                                                                                                                                                                                          instance Batteries.RBMap.instCoeHeadKeysList {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                                          CoeHead (Keys α β cmp) (List α)
                                                                                                                                                                                                                                                                          @[implicit_reducible]
                                                                                                                                                                                                                                                                          instance Batteries.RBMap.instForInKeysOfMonad {α : Type u} {β : Type v} {cmp : α → α → Ordering} {m : Type u_1 → Type u_2} [Monad m] :
                                                                                                                                                                                                                                                                          ForIn m (Keys α β cmp) α
                                                                                                                                                                                                                                                                          @[implicit_reducible]
                                                                                                                                                                                                                                                                          instance Batteries.RBMap.instForMKeysOfMonad {α : Type u} {β : Type v} {cmp : α → α → Ordering} {m : Type u_1 → Type u_2} [Monad m] :
                                                                                                                                                                                                                                                                          ForM m (Keys α β cmp) α
                                                                                                                                                                                                                                                                          def Batteries.RBMap.Keys.Stream (α : Type u_1) (β : Type u_2) :
                                                                                                                                                                                                                                                                          Type (max u_2 u_1)

                                                                                                                                                                                                                                                                          The result of toStream on a Keys.

                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                            def Batteries.RBMap.Keys.toStream {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : Keys α β cmp) :
                                                                                                                                                                                                                                                                            Stream α β

                                                                                                                                                                                                                                                                            A stream over the iterator.

                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                              def Batteries.RBMap.Keys.Stream.next? {α : Type u} {β : Type v} (t : Stream α β) :
                                                                                                                                                                                                                                                                              Option (α × Stream α β)

                                                                                                                                                                                                                                                                              O(1) amortized, O(log n) worst case: Get the next element from the stream.

                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                @[implicit_reducible]
                                                                                                                                                                                                                                                                                instance Batteries.RBMap.instToStreamKeysStream {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                                                Std.ToStream (Keys α β cmp) (Keys.Stream α β)
                                                                                                                                                                                                                                                                                @[implicit_reducible]
                                                                                                                                                                                                                                                                                instance Batteries.RBMap.instStreamStream {α : Type u} {β : Type v} :
                                                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                                                def Batteries.RBMap.valuesArray {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) :

                                                                                                                                                                                                                                                                                O(n). Constructs the array of values of the map.

                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                                                  def Batteries.RBMap.valuesList {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) :
                                                                                                                                                                                                                                                                                  List β

                                                                                                                                                                                                                                                                                  O(n). Constructs the list of values of the map.

                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                    def Batteries.RBMap.Values (α : Type u_1) (β : Type u_2) (cmp : α → α → Ordering) :
                                                                                                                                                                                                                                                                                    Type (max u_1 u_2)

                                                                                                                                                                                                                                                                                    An "iterator" over the values of the map. This is a trivial wrapper over the underlying map, but it comes with a small API to use it in a for loop or convert it to an array or list.

                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                                                      def Batteries.RBMap.values {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) :
                                                                                                                                                                                                                                                                                      Values α β cmp

                                                                                                                                                                                                                                                                                      The "keys" of the map. This is an O(1) wrapper operation, which can be used in for loops or converted to an array or list.

                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                                                                        def Batteries.RBMap.Values.toArray {α : Type u_1} {β : Type u_2} {cmp : α → α → Ordering} (t : RBMap α β cmp) :

                                                                                                                                                                                                                                                                                        O(n). Constructs the array of values of the map.

                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                          @[inline]
                                                                                                                                                                                                                                                                                          def Batteries.RBMap.Values.toList {α : Type u_1} {β : Type u_2} {cmp : α → α → Ordering} (t : RBMap α β cmp) :
                                                                                                                                                                                                                                                                                          List β

                                                                                                                                                                                                                                                                                          O(n). Constructs the list of values of the map.

                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                            @[implicit_reducible]
                                                                                                                                                                                                                                                                                            instance Batteries.RBMap.instCoeHeadValuesArray {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                                                            CoeHead (Values α β cmp) (Array β)
                                                                                                                                                                                                                                                                                            @[implicit_reducible]
                                                                                                                                                                                                                                                                                            instance Batteries.RBMap.instCoeHeadValuesList {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                                                            CoeHead (Values α β cmp) (List β)
                                                                                                                                                                                                                                                                                            @[implicit_reducible]
                                                                                                                                                                                                                                                                                            instance Batteries.RBMap.instForInValuesOfMonad {α : Type u} {β : Type v} {cmp : α → α → Ordering} {m : Type u_1 → Type u_2} [Monad m] :
                                                                                                                                                                                                                                                                                            ForIn m (Values α β cmp) β
                                                                                                                                                                                                                                                                                            @[implicit_reducible]
                                                                                                                                                                                                                                                                                            instance Batteries.RBMap.instForMValuesOfMonad {α : Type u} {β : Type v} {cmp : α → α → Ordering} {m : Type u_1 → Type u_2} [Monad m] :
                                                                                                                                                                                                                                                                                            ForM m (Values α β cmp) β
                                                                                                                                                                                                                                                                                            def Batteries.RBMap.Values.Stream (α : Type u_1) (β : Type u_2) :
                                                                                                                                                                                                                                                                                            Type (max u_2 u_1)

                                                                                                                                                                                                                                                                                            The result of toStream on a Values.

                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                              def Batteries.RBMap.Values.toStream {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : Values α β cmp) :
                                                                                                                                                                                                                                                                                              Stream α β

                                                                                                                                                                                                                                                                                              A stream over the iterator.

                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                def Batteries.RBMap.Values.Stream.next? {α : Type u} {β : Type v} (t : Stream α β) :
                                                                                                                                                                                                                                                                                                Option (β × Stream α β)

                                                                                                                                                                                                                                                                                                O(1) amortized, O(log n) worst case: Get the next element from the stream.

                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                  @[implicit_reducible]
                                                                                                                                                                                                                                                                                                  instance Batteries.RBMap.instToStreamValuesStream {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                                                                  Std.ToStream (Values α β cmp) (Values.Stream α β)
                                                                                                                                                                                                                                                                                                  @[implicit_reducible]
                                                                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                                                                  def Batteries.RBMap.isEmpty {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                                                                  RBMap α β cmp → Bool

                                                                                                                                                                                                                                                                                                  O(1). Is the tree empty?

                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                                                                                                    def Batteries.RBMap.toList {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                                                                    RBMap α β cmp → List (α × β)

                                                                                                                                                                                                                                                                                                    O(n). Convert the tree to a list in ascending order.

                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                                                                      def Batteries.RBMap.min? {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                                                                      RBMap α β cmp → Option (α × β)

                                                                                                                                                                                                                                                                                                      O(log n). Returns the key-value pair (a, b) such that a ≤ k for all keys in the RBMap.

                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                                                                                        def Batteries.RBMap.max? {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                                                                        RBMap α β cmp → Option (α × β)

                                                                                                                                                                                                                                                                                                        O(log n). Returns the key-value pair (a, b) such that a ≥ k for all keys in the RBMap.

                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                          @[implicit_reducible]
                                                                                                                                                                                                                                                                                                          instance Batteries.RBMap.instRepr {α : Type u} {β : Type v} {cmp : α → α → Ordering} [Repr α] [Repr β] :
                                                                                                                                                                                                                                                                                                          Repr (RBMap α β cmp)
                                                                                                                                                                                                                                                                                                          @[inline]
                                                                                                                                                                                                                                                                                                          def Batteries.RBMap.insert {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) (k : α) (v : β) :
                                                                                                                                                                                                                                                                                                          RBMap α β cmp

                                                                                                                                                                                                                                                                                                          O(log n). Insert key-value pair (k, v) into the tree.

                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                            @[inline]
                                                                                                                                                                                                                                                                                                            def Batteries.RBMap.erase {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) (k : α) :
                                                                                                                                                                                                                                                                                                            RBMap α β cmp

                                                                                                                                                                                                                                                                                                            O(log n). Remove an element k from the map.

                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                                                                                                                              def Batteries.RBMap.ofList {α : Type u} {β : Type v} (l : List (α × β)) (cmp : α → α → Ordering) :
                                                                                                                                                                                                                                                                                                              RBMap α β cmp

                                                                                                                                                                                                                                                                                                              O(n log n). Build a tree from an unsorted list by inserting them one at a time.

                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                                                                                def Batteries.RBMap.ofArray {α : Type u} {β : Type v} (l : Array (α × β)) (cmp : α → α → Ordering) :
                                                                                                                                                                                                                                                                                                                RBMap α β cmp

                                                                                                                                                                                                                                                                                                                O(n log n). Build a tree from an unsorted array by inserting them one at a time.

                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                                                                                  def Batteries.RBMap.findEntry? {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) (k : α) :
                                                                                                                                                                                                                                                                                                                  Option (α × β)

                                                                                                                                                                                                                                                                                                                  O(log n). Find an entry in the tree with key equal to k.

                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                                                                                                                    def Batteries.RBMap.find? {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) (k : α) :

                                                                                                                                                                                                                                                                                                                    O(log n). Find the value corresponding to key k.

                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                                                                                      def Batteries.RBMap.findD {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) (k : α) (v₀ : β) :
                                                                                                                                                                                                                                                                                                                      β

                                                                                                                                                                                                                                                                                                                      O(log n). Find the value corresponding to key k, or return v₀ if it is not in the map.

                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                                                                                                        def Batteries.RBMap.lowerBound? {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) (k : α) :
                                                                                                                                                                                                                                                                                                                        Option (α × β)

                                                                                                                                                                                                                                                                                                                        O(log n). lowerBound? k retrieves the key-value pair of the largest key smaller than or equal to k, if it exists.

                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                          @[inline]
                                                                                                                                                                                                                                                                                                                          def Batteries.RBMap.contains {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) (a : α) :

                                                                                                                                                                                                                                                                                                                          O(log n). Returns true if the given key a is in the RBMap.

                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                            @[inline]
                                                                                                                                                                                                                                                                                                                            def Batteries.RBMap.all {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) (p : α → β → Bool) :

                                                                                                                                                                                                                                                                                                                            O(n). Returns true if the given predicate is true for all items in the RBMap.

                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                                                                                                                                              def Batteries.RBMap.any {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) (p : α → β → Bool) :

                                                                                                                                                                                                                                                                                                                              O(n). Returns true if the given predicate is true for any item in the RBMap.

                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                                                                                                def Batteries.RBMap.all₂ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {cmpα : α → α → Ordering} {cmpγ : γ → γ → Ordering} (R : α × β → γ × δ → Bool) (t₁ : RBMap α β cmpα) (t₂ : RBMap γ δ cmpγ) :

                                                                                                                                                                                                                                                                                                                                Asserts that t₁ and t₂ have the same number of elements in the same order, and R holds pairwise between them. The tree structure is ignored.

                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                                                                                                  def Batteries.RBMap.eqKeys {α : Type u} {β : Type v} {cmp : α → α → Ordering} {γ : Type u_1} (t₁ : RBMap α β cmp) (t₂ : RBMap α γ cmp) :

                                                                                                                                                                                                                                                                                                                                  Asserts that t₁ and t₂ have the same set of keys (up to equality).

                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                    @[implicit_reducible]
                                                                                                                                                                                                                                                                                                                                    instance Batteries.RBMap.instBEq {α : Type u} {β : Type v} {cmp : α → α → Ordering} [BEq α] [BEq β] :
                                                                                                                                                                                                                                                                                                                                    BEq (RBMap α β cmp)

                                                                                                                                                                                                                                                                                                                                    Returns true if t₁ and t₂ have the same keys and values (assuming cmp and == are compatible), ignoring the internal tree structure.

                                                                                                                                                                                                                                                                                                                                    def Batteries.RBMap.size {α : Type u} {β : Type v} {cmp : α → α → Ordering} :
                                                                                                                                                                                                                                                                                                                                    RBMap α β cmp → Nat

                                                                                                                                                                                                                                                                                                                                    O(n). The number of items in the RBMap.

                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                                                                                                      def Batteries.RBMap.min! {α : Type u} {β : Type v} {cmp : α → α → Ordering} [Inhabited α] [Inhabited β] :
                                                                                                                                                                                                                                                                                                                                      RBMap α β cmp → α × β

                                                                                                                                                                                                                                                                                                                                      O(log n). Returns the minimum element of the map, or panics if the map is empty.

                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                                                                                                                        def Batteries.RBMap.max! {α : Type u} {β : Type v} {cmp : α → α → Ordering} [Inhabited α] [Inhabited β] :
                                                                                                                                                                                                                                                                                                                                        RBMap α β cmp → α × β

                                                                                                                                                                                                                                                                                                                                        O(log n). Returns the maximum element of the map, or panics if the map is empty.

                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                          @[inline]
                                                                                                                                                                                                                                                                                                                                          def Batteries.RBMap.find! {α : Type u} {β : Type v} {cmp : α → α → Ordering} [Inhabited β] (t : RBMap α β cmp) (k : α) :
                                                                                                                                                                                                                                                                                                                                          β

                                                                                                                                                                                                                                                                                                                                          Attempts to find the value with key k : α in t and panics if there is no such key.

                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                            def Batteries.RBMap.mergeWith {α : Type u} {β : Type v} {cmp : α → α → Ordering} (mergeFn : α → β → β → β) (t₁ t₂ : RBMap α β cmp) :
                                                                                                                                                                                                                                                                                                                                            RBMap α β cmp

                                                                                                                                                                                                                                                                                                                                            O(n₂ * log (n₁ + n₂)). Merges the maps t₁ and t₂, if a key a : α exists in both, then use mergeFn a b₁ b₂ to produce the new merged value.

                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                              def Batteries.RBMap.intersectWith {α : Type u} {β : Type v} {cmp : α → α → Ordering} {γ : Type u_1} {δ : Type u_2} (mergeFn : α → β → γ → δ) (t₁ : RBMap α β cmp) (t₂ : RBMap α γ cmp) :
                                                                                                                                                                                                                                                                                                                                              RBMap α δ cmp

                                                                                                                                                                                                                                                                                                                                              O(n₁ * log (n₁ + n₂)). Intersects the maps t₁ and t₂ using mergeFn a b to produce the new value.

                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                def Batteries.RBMap.filter {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t : RBMap α β cmp) (p : α → β → Bool) :
                                                                                                                                                                                                                                                                                                                                                RBMap α β cmp

                                                                                                                                                                                                                                                                                                                                                O(n * log n). Constructs the set of all elements satisfying p.

                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                  def Batteries.RBMap.sdiff {α : Type u} {β : Type v} {cmp : α → α → Ordering} (t₁ t₂ : RBMap α β cmp) :
                                                                                                                                                                                                                                                                                                                                                  RBMap α β cmp

                                                                                                                                                                                                                                                                                                                                                  O(n₁ * (log n₁ + log n₂)). Constructs the set of all elements of t₁ that are not in t₂.

                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                    @[reducible, inline]
                                                                                                                                                                                                                                                                                                                                                    abbrev List.toRBMap {α : Type u_1} {β : Type u_2} (l : List (α × β)) (cmp : α → α → Ordering) :
                                                                                                                                                                                                                                                                                                                                                    Batteries.RBMap α β cmp

                                                                                                                                                                                                                                                                                                                                                    O(n log n). Build a tree from an unsorted list by inserting them one at a time.

                                                                                                                                                                                                                                                                                                                                                    Instances For