Documentation

Std.Data.RBMap.Basic

Red-black trees #

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.

inductive Std.RBColor :

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: Std.RBColor

    A red node is required to have black children.

  • black: Std.RBColor

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

Instances For
    inductive Std.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

    Instances For
      instance Std.instReprRBNode :
      {α : Type u_1} → [inst : Repr α] → Repr (Std.RBNode α)
      Equations
      • Std.instReprRBNode = { reprPrec := Std.reprRBNode✝ }
      Equations
      • Std.RBNode.instEmptyCollectionRBNode = { emptyCollection := Std.RBNode.nil }
      def Std.RBNode.min? {α : Type u_1} :
      Std.RBNode αOption α

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

      Equations
      Instances For
        def Std.RBNode.max? {α : Type u_1} :
        Std.RBNode αOption α

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

        Equations
        Instances For
          @[deprecated Std.RBNode.min?]
          def Std.RBNode.min {α : Type u_1} :
          Std.RBNode αOption α

          Alias of Std.RBNode.min?.


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

          Equations
          Instances For
            @[deprecated Std.RBNode.max?]
            def Std.RBNode.max {α : Type u_1} :
            Std.RBNode αOption α

            Alias of Std.RBNode.max?.


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

            Equations
            Instances For
              @[specialize #[]]
              def Std.RBNode.fold {σ : Sort u_1} {α : Type u_2} (v₀ : σ) (f : σασσ) :
              Std.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.

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

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

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

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

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

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

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

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

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

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

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

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

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

                            Inner loop of forIn.

                            Equations
                            Instances For
                              instance Std.RBNode.instForInRBNode {m : Type u_1 → Type u_2} {α : Type u_3} :
                              ForIn m (Std.RBNode α) α
                              Equations
                              • Std.RBNode.instForInRBNode = { forIn := fun {β : Type u_1} [Monad m] => Std.RBNode.forIn }
                              inductive Std.RBNode.Stream (α : Type u_1) :
                              Type u_1

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

                              Instances For
                                def Std.RBNode.toStream {α : Type u_1} :
                                Std.RBNode αoptParam (Std.RBNode.Stream α) Std.RBNode.Stream.nilStd.RBNode.Stream α

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

                                Equations
                                Instances For

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

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

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

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

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

                                      Equations
                                      Instances For

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

                                        Equations
                                        Instances For
                                          Equations
                                          Equations
                                          • Std.RBNode.instStreamStream = { next? := Std.RBNode.Stream.next? }
                                          @[specialize #[]]
                                          def Std.RBNode.all {α : Type u_1} (p : αBool) :

                                          Returns true iff every element of the tree satisfies p.

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

                                            Returns true iff any element of the tree satisfies p.

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

                                              Asserts that p holds on every element of the tree.

                                              Equations
                                              Instances For
                                                theorem Std.RBNode.All.imp {α : Type u_1} {p : αProp} {q : αProp} (H : ∀ {x : α}, p xq x) {t : Std.RBNode α} :
                                                theorem Std.RBNode.all_iff {α : Type u_1} {p : αBool} {t : Std.RBNode α} :
                                                Std.RBNode.all p t = true Std.RBNode.All (fun (x : α) => p x = true) t
                                                instance Std.RBNode.instDecidableAll {α : Type u_1} {p : αProp} {t : Std.RBNode α} [DecidablePred p] :
                                                Equations
                                                def Std.RBNode.Any {α : Type u_1} (p : αProp) :

                                                Asserts that p holds on some element of the tree.

                                                Equations
                                                Instances For
                                                  theorem Std.RBNode.any_iff {α : Type u_1} {p : αBool} {t : Std.RBNode α} :
                                                  Std.RBNode.any p t = true Std.RBNode.Any (fun (x : α) => p x = true) t
                                                  instance Std.RBNode.instDecidableAny {α : Type u_1} {p : αProp} {t : Std.RBNode α} [DecidablePred p] :
                                                  Equations
                                                  def Std.RBNode.EMem {α : Type u_1} (x : α) (t : Std.RBNode α) :

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

                                                  Equations
                                                  Instances For
                                                    Equations
                                                    • Std.RBNode.instMembershipRBNode = { mem := Std.RBNode.EMem }
                                                    def Std.RBNode.MemP {α : Type u_1} (cut : αOrdering) (t : Std.RBNode α) :

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

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

                                                      True if x is equivalent to an element of t.

                                                      Equations
                                                      Instances For
                                                        Equations
                                                        Instances For
                                                          def Std.RBNode.Slow.instDecidableMemP {α : Type u_1} {cut : αOrdering} {t : Std.RBNode α} :
                                                          Equations
                                                          Instances For
                                                            def Std.RBNode.Slow.instDecidableMem {α : Type u_1} {cmp : ααOrdering} {x : α} {t : Std.RBNode α} :
                                                            Equations
                                                            Instances For
                                                              @[specialize #[]]
                                                              def Std.RBNode.all₂ {α : Type u_1} {β : Type u_2} (R : αβBool) (t₁ : Std.RBNode α) (t₂ : Std.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.

                                                              Equations
                                                              • One or more equations did not get rendered due to their size.
                                                              Instances For
                                                                instance Std.RBNode.instBEqRBNode {α : Type u_1} [BEq α] :
                                                                Equations
                                                                def Std.RBNode.cmpLT {α : Sort 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 ∀ [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 [TransCmp cmp] binder from being introduced when we don't want it.
                                                                Equations
                                                                Instances For
                                                                  theorem Std.RBNode.cmpLT_iff :
                                                                  ∀ {α : Sort u_1} {cmp : ααOrdering} {x y : α} [inst : Std.TransCmp cmp], Std.RBNode.cmpLT cmp x y cmp x y = Ordering.lt
                                                                  instance Std.RBNode.instDecidableCmpLT :
                                                                  {α : Sort u_1} → {x y : α} → (cmp : ααOrdering) → [inst : Std.TransCmp cmp] → Decidable (Std.RBNode.cmpLT cmp x y)
                                                                  Equations
                                                                  def Std.RBNode.cmpEq {α : Sort u_1} (cmp : ααOrdering) (x : α) (y : α) :

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

                                                                  Equations
                                                                  Instances For
                                                                    theorem Std.RBNode.cmpEq_iff :
                                                                    ∀ {α : Sort u_1} {cmp : ααOrdering} {x y : α} [inst : Std.TransCmp cmp], Std.RBNode.cmpEq cmp x y cmp x y = Ordering.eq
                                                                    instance Std.RBNode.instDecidableCmpEq :
                                                                    {α : Sort u_1} → {x y : α} → (cmp : ααOrdering) → [inst : Std.TransCmp cmp] → Decidable (Std.RBNode.cmpEq cmp x y)
                                                                    Equations
                                                                    def Std.RBNode.isOrdered {α : Type u_1} (cmp : ααOrdering) (t : Std.RBNode α) (l : optParam (Option α) none) (r : optParam (Option α) none) :

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

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

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

                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For
                                                                        @[inline]
                                                                        def Std.RBNode.balance2 {α : Type u_1} :
                                                                        Std.RBNode ααStd.RBNode αStd.RBNode α

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

                                                                        Equations
                                                                        • One or more equations did not get rendered due to their size.
                                                                        Instances For
                                                                          @[inline]

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

                                                                          Equations
                                                                          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.)

                                                                            Equations
                                                                            Instances For
                                                                              def Std.RBNode.setBlack {α : Type u_1} :

                                                                              Changes the color of the root to black.

                                                                              Equations
                                                                              Instances For
                                                                                def Std.RBNode.reverse {α : Type u_1} :

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

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

                                                                                  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.

                                                                                  Equations
                                                                                  Instances For
                                                                                    @[specialize #[]]
                                                                                    def Std.RBNode.insert {α : Type u_1} (cmp : ααOrdering) (t : Std.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.

                                                                                    Equations
                                                                                    Instances For
                                                                                      def Std.RBNode.setRed {α : Type u_1} :

                                                                                      Recolor the root of the tree to red if possible.

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

                                                                                        Rebalancing a tree which has shrunk on the left.

                                                                                        Equations
                                                                                        • One or more equations did not get rendered due to their size.
                                                                                        Instances For
                                                                                          def Std.RBNode.balRight {α : Type u_1} (l : Std.RBNode α) (v : α) (r : Std.RBNode α) :

                                                                                          Rebalancing a tree which has shrunk on the right.

                                                                                          Equations
                                                                                          • One or more equations did not get rendered due to their size.
                                                                                          Instances For
                                                                                            def Std.RBNode.size {α : Type u_1} :

                                                                                            The number of nodes in the tree.

                                                                                            Equations
                                                                                            Instances For
                                                                                              def Std.RBNode.append {α : Type u_1} :

                                                                                              Concatenate two trees with the same black-height.

                                                                                              Equations
                                                                                              Instances For

                                                                                                erase #

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

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

                                                                                                Equations
                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                • Std.RBNode.del cut Std.RBNode.nil = Std.RBNode.nil
                                                                                                Instances For
                                                                                                  @[specialize #[]]
                                                                                                  def Std.RBNode.erase {α : Type u_1} (cut : αOrdering) (t : Std.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.)

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

                                                                                                    Finds an element in the tree satisfying the cut function.

                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    • Std.RBNode.find? cut Std.RBNode.nil = none
                                                                                                    Instances For
                                                                                                      @[specialize #[]]
                                                                                                      def Std.RBNode.lowerBound? {α : Type u_1} (cut : αOrdering) :
                                                                                                      Std.RBNode αOption αOption α

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

                                                                                                      Equations
                                                                                                      Instances For
                                                                                                        def Std.RBNode.root? {α : Type u_1} :
                                                                                                        Std.RBNode αOption α

                                                                                                        Returns the root of the tree, if any.

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

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

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

                                                                                                            Converts the tree into an array in increasing sorted order.

                                                                                                            Equations
                                                                                                            Instances For
                                                                                                              inductive Std.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.

                                                                                                              Instances For

                                                                                                                Fills the Path with a subtree.

                                                                                                                Equations
                                                                                                                Instances For
                                                                                                                  @[specialize #[]]
                                                                                                                  def Std.RBNode.zoom {α : Type u_1} (cut : αOrdering) :
                                                                                                                  Std.RBNode αoptParam (Std.RBNode.Path α) Std.RBNode.Path.rootStd.RBNode α × Std.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.

                                                                                                                  Equations
                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                  • Std.RBNode.zoom cut Std.RBNode.nil x = (Std.RBNode.nil, x)
                                                                                                                  Instances For
                                                                                                                    @[inline]
                                                                                                                    def Std.RBNode.Path.insertNew {α : Type u_1} (path : Std.RBNode.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.

                                                                                                                    Equations
                                                                                                                    Instances For
                                                                                                                      def Std.RBNode.Path.insert {α : Type u_1} (path : Std.RBNode.Path α) (t : Std.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).

                                                                                                                      Equations
                                                                                                                      Instances For

                                                                                                                        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).

                                                                                                                        Equations
                                                                                                                        Instances For
                                                                                                                          def Std.RBNode.Path.erase {α : Type u_1} (path : Std.RBNode.Path α) (t : Std.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.

                                                                                                                          Equations
                                                                                                                          Instances For
                                                                                                                            @[specialize #[]]
                                                                                                                            def Std.RBNode.modify {α : Type u_1} (cut : αOrdering) (f : αα) (t : Std.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.

                                                                                                                            Equations
                                                                                                                            Instances For
                                                                                                                              @[specialize #[]]
                                                                                                                              def Std.RBNode.alter {α : Type u_1} (cut : αOrdering) (f : Option αOption α) (t : Std.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.

                                                                                                                              Equations
                                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                                              Instances For
                                                                                                                                def Std.RBNode.Ordered {α : Type u_1} (cmp : ααOrdering) :

                                                                                                                                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.

                                                                                                                                Equations
                                                                                                                                Instances For
                                                                                                                                  def Std.RBNode.Slow.instDecidableOrdered {α : Type u_1} (cmp : ααOrdering) [Std.TransCmp cmp] (t : Std.RBNode α) :
                                                                                                                                  Equations
                                                                                                                                  Instances For
                                                                                                                                    inductive Std.RBNode.Balanced {α : Type u_1} :

                                                                                                                                    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 Std.RBNode.WF {α : Type u_1} (cmp : ααOrdering) :

                                                                                                                                      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 Std.Data.RBMap.Lemmas.

                                                                                                                                      Instances For
                                                                                                                                        def Std.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.

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

                                                                                                                                          O(1). Construct a new empty tree.

                                                                                                                                          Equations
                                                                                                                                          • Std.mkRBSet α cmp = { val := Std.RBNode.nil, property := }
                                                                                                                                          Instances For
                                                                                                                                            @[inline]
                                                                                                                                            def Std.RBSet.empty {α : Type u_1} {cmp : ααOrdering} :
                                                                                                                                            Std.RBSet α cmp

                                                                                                                                            O(1). Construct a new empty tree.

                                                                                                                                            Equations
                                                                                                                                            Instances For
                                                                                                                                              instance Std.RBSet.instEmptyCollectionRBSet (α : Type u) (cmp : ααOrdering) :
                                                                                                                                              Equations
                                                                                                                                              instance Std.RBSet.instInhabitedRBSet (α : Type u) (cmp : ααOrdering) :
                                                                                                                                              Equations
                                                                                                                                              @[inline]
                                                                                                                                              def Std.RBSet.single {α : Type u_1} {cmp : ααOrdering} (v : α) :
                                                                                                                                              Std.RBSet α cmp

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

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

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

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

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

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

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

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

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

                                                                                                                                                      Equations
                                                                                                                                                      Instances For
                                                                                                                                                        instance Std.RBSet.instForInRBSet {m : Type u_1 → Type u_2} {α : Type u_3} {cmp : ααOrdering} :
                                                                                                                                                        ForIn m (Std.RBSet α cmp) α
                                                                                                                                                        Equations
                                                                                                                                                        instance Std.RBSet.instToStreamRBSetStream {α : Type u_1} {cmp : ααOrdering} :
                                                                                                                                                        Equations
                                                                                                                                                        @[inline]
                                                                                                                                                        def Std.RBSet.isEmpty {α : Type u_1} {cmp : ααOrdering} :
                                                                                                                                                        Std.RBSet α cmpBool

                                                                                                                                                        O(1). Is the tree empty?

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

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

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

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

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

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

                                                                                                                                                              Equations
                                                                                                                                                              Instances For
                                                                                                                                                                @[deprecated Std.RBSet.min?]
                                                                                                                                                                def Std.RBSet.min {α : Type u_1} {cmp : ααOrdering} (t : Std.RBSet α cmp) :

                                                                                                                                                                Alias of Std.RBSet.min?.


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

                                                                                                                                                                Equations
                                                                                                                                                                Instances For
                                                                                                                                                                  @[deprecated Std.RBSet.max?]
                                                                                                                                                                  def Std.RBSet.max {α : Type u_1} {cmp : ααOrdering} (t : Std.RBSet α cmp) :

                                                                                                                                                                  Alias of Std.RBSet.max?.


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

                                                                                                                                                                  Equations
                                                                                                                                                                  Instances For
                                                                                                                                                                    instance Std.RBSet.instReprRBSet {α : Type u_1} {cmp : ααOrdering} [Repr α] :
                                                                                                                                                                    Repr (Std.RBSet α cmp)
                                                                                                                                                                    Equations
                                                                                                                                                                    @[inline]
                                                                                                                                                                    def Std.RBSet.insert {α : Type u_1} {cmp : ααOrdering} (t : Std.RBSet α cmp) (v : α) :
                                                                                                                                                                    Std.RBSet α cmp

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

                                                                                                                                                                    Equations
                                                                                                                                                                    Instances For
                                                                                                                                                                      @[inline]
                                                                                                                                                                      def Std.RBSet.erase {α : Type u_1} {cmp : ααOrdering} (t : Std.RBSet α cmp) (cut : αOrdering) :
                                                                                                                                                                      Std.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.)

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

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

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

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

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

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

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

                                                                                                                                                                              O(log n). lowerBoundP cut retrieves the largest entry comparing lt or eq under cut, if it exists.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                                                                                                                            Equations
                                                                                                                                                                                            Instances For
                                                                                                                                                                                              @[inline]
                                                                                                                                                                                              def Std.RBSet.all₂ {α : Type u_1} {β : Type u_2} {cmpα : ααOrdering} {cmpβ : ββOrdering} (R : αβBool) (t₁ : Std.RBSet α cmpα) (t₂ : Std.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.

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

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

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

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

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

                                                                                                                                                                                                    True if x is equivalent to an element of t.

                                                                                                                                                                                                    Equations
                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                      instance Std.RBSet.instMembershipRBSet {α : Type u_1} {cmp : ααOrdering} :
                                                                                                                                                                                                      Membership α (Std.RBSet α cmp)
                                                                                                                                                                                                      Equations
                                                                                                                                                                                                      • Std.RBSet.instMembershipRBSet = { mem := Std.RBSet.Mem }
                                                                                                                                                                                                      def Std.RBSet.Slow.instDecidableEMem {α : Type u_1} {cmp : ααOrdering} {x : α} [DecidableEq α] {t : Std.RBSet α cmp} :
                                                                                                                                                                                                      Equations
                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                        def Std.RBSet.Slow.instDecidableMemP {α : Type u_1} {cmp : ααOrdering} {cut : αOrdering} {t : Std.RBSet α cmp} :
                                                                                                                                                                                                        Equations
                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                          def Std.RBSet.Slow.instDecidableMem {α : Type u_1} {cmp : ααOrdering} {x : α} {t : Std.RBSet α cmp} :
                                                                                                                                                                                                          Equations
                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                            instance Std.RBSet.instBEqRBSet {α : Type u_1} {cmp : ααOrdering} [BEq α] :
                                                                                                                                                                                                            BEq (Std.RBSet α cmp)

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

                                                                                                                                                                                                            Equations
                                                                                                                                                                                                            def Std.RBSet.size {α : Type u_1} {cmp : ααOrdering} (m : Std.RBSet α cmp) :

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

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

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

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

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

                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                  def Std.RBSet.findP! {α : Type u_1} {cmp : ααOrdering} [Inhabited α] (t : Std.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.

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

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

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

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

                                                                                                                                                                                                                      Instances
                                                                                                                                                                                                                        def Std.RBSet.modifyP {α : Type u_1} {cmp : ααOrdering} (t : Std.RBSet α cmp) (cut : αOrdering) (f : αα) [wf : Std.RBSet.ModifyWF t cut f] :
                                                                                                                                                                                                                        Std.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.

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

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

                                                                                                                                                                                                                          Instances
                                                                                                                                                                                                                            def Std.RBSet.alterP {α : Type u_1} {cmp : ααOrdering} (t : Std.RBSet α cmp) (cut : αOrdering) (f : Option αOption α) [wf : Std.RBSet.AlterWF t cut f] :
                                                                                                                                                                                                                            Std.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.

                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                              def Std.RBSet.union {α : Type u_1} {cmp : ααOrdering} (t₁ : Std.RBSet α cmp) (t₂ : Std.RBSet α cmp) :
                                                                                                                                                                                                                              Std.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.

                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                def Std.RBSet.mergeWith {α : Type u_1} {cmp : ααOrdering} (mergeFn : ααα) (t₁ : Std.RBSet α cmp) (t₂ : Std.RBSet α cmp) :
                                                                                                                                                                                                                                Std.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.

                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                  def Std.RBSet.intersectWith {α : Type u_1} {β : Type u_2} {γ : Type u_3} {cmpα : ααOrdering} {cmpβ : ββOrdering} {cmpγ : γγOrdering} (cmp : αβOrdering) (mergeFn : αβγ) (t₁ : Std.RBSet α cmpα) (t₂ : Std.RBSet β cmpβ) :
                                                                                                                                                                                                                                  Std.RBSet γ cmpγ

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

                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                    def Std.RBSet.filter {α : Type u_1} {cmp : ααOrdering} (t : Std.RBSet α cmp) (p : αBool) :
                                                                                                                                                                                                                                    Std.RBSet α cmp

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

                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                      def Std.RBSet.map {α : Type u_1} {cmpα : ααOrdering} {β : Type u_2} {cmpβ : ββOrdering} (t : Std.RBSet α cmpα) (f : αβ) :
                                                                                                                                                                                                                                      Std.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.

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

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

                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                          def Std.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.

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

                                                                                                                                                                                                                                            O(1). Construct a new empty map.

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

                                                                                                                                                                                                                                              O(1). Construct a new empty map.

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

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

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

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

                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                                                    def Std.RBMap.foldr {α : Type u} {β : Type v} {σ : Type w} {cmp : ααOrdering} (f : αβσσ) (init : σ) :
                                                                                                                                                                                                                                                    Std.RBMap α β cmpσ

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

                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                      def Std.RBMap.foldlM {α : Type u} {β : Type v} {σ : Type w} {cmp : ααOrdering} {m : Type w → Type u_1} [Monad m] (f : σαβm σ) (init : σ) :
                                                                                                                                                                                                                                                      Std.RBMap α β cmpm σ

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

                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                                        def Std.RBMap.forM {α : Type u} {β : Type v} {cmp : ααOrdering} {m : Type u_1 → Type u_2} [Monad m] (f : αβm PUnit) (t : Std.RBMap α β cmp) :

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

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

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

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

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

                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                              def Std.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.

                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                                def Std.RBMap.keys {α : Type u} {β : Type v} {cmp : ααOrdering} (t : Std.RBMap α β cmp) :
                                                                                                                                                                                                                                                                Std.RBMap.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.

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

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

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

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

                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                      instance Std.RBMap.instCoeHeadKeysArray {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                      CoeHead (Std.RBMap.Keys α β cmp) (Array α)
                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                      • Std.RBMap.instCoeHeadKeysArray = { coe := Std.RBMap.keysArray }
                                                                                                                                                                                                                                                                      instance Std.RBMap.instCoeHeadKeysList {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                      CoeHead (Std.RBMap.Keys α β cmp) (List α)
                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                      • Std.RBMap.instCoeHeadKeysList = { coe := Std.RBMap.keysList }
                                                                                                                                                                                                                                                                      instance Std.RBMap.instForInKeys {α : Type u} {β : Type v} {cmp : ααOrdering} {m : Type u_1 → Type u_2} :
                                                                                                                                                                                                                                                                      ForIn m (Std.RBMap.Keys α β cmp) α
                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                      instance Std.RBMap.instForMKeys {α : Type u} {β : Type v} {cmp : ααOrdering} {m : Type u_1 → Type u_2} :
                                                                                                                                                                                                                                                                      ForM m (Std.RBMap.Keys α β cmp) α
                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                      def Std.RBMap.Keys.Stream (α : Type u_1) (β : Type u_2) :
                                                                                                                                                                                                                                                                      Type (max u_2 u_1)

                                                                                                                                                                                                                                                                      The result of toStream on a Keys.

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

                                                                                                                                                                                                                                                                        A stream over the iterator.

                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                        Instances For

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

                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                            instance Std.RBMap.instToStreamKeysStream {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                            • Std.RBMap.instToStreamKeysStream = { toStream := Std.RBMap.Keys.toStream }
                                                                                                                                                                                                                                                                            instance Std.RBMap.instStreamStream {α : Type u} {β : Type v} :
                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                            • Std.RBMap.instStreamStream = { next? := Std.RBMap.Keys.Stream.next? }
                                                                                                                                                                                                                                                                            @[inline]
                                                                                                                                                                                                                                                                            def Std.RBMap.valuesArray {α : Type u} {β : Type v} {cmp : ααOrdering} (t : Std.RBMap α β cmp) :

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

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

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

                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                def Std.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.

                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                                                  def Std.RBMap.values {α : Type u} {β : Type v} {cmp : ααOrdering} (t : Std.RBMap α β 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.

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

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

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

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

                                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                        instance Std.RBMap.instCoeHeadValuesArray {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                                        CoeHead (Std.RBMap.Values α β cmp) (Array β)
                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                        • Std.RBMap.instCoeHeadValuesArray = { coe := Std.RBMap.valuesArray }
                                                                                                                                                                                                                                                                                        instance Std.RBMap.instCoeHeadValuesList {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                                        CoeHead (Std.RBMap.Values α β cmp) (List β)
                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                        • Std.RBMap.instCoeHeadValuesList = { coe := Std.RBMap.valuesList }
                                                                                                                                                                                                                                                                                        instance Std.RBMap.instForInValues {α : Type u} {β : Type v} {cmp : ααOrdering} {m : Type u_1 → Type u_2} :
                                                                                                                                                                                                                                                                                        ForIn m (Std.RBMap.Values α β cmp) β
                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                        instance Std.RBMap.instForMValues {α : Type u} {β : Type v} {cmp : ααOrdering} {m : Type u_1 → Type u_2} :
                                                                                                                                                                                                                                                                                        ForM m (Std.RBMap.Values α β cmp) β
                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                        def Std.RBMap.Values.Stream (α : Type u_1) (β : Type u_2) :
                                                                                                                                                                                                                                                                                        Type (max u_2 u_1)

                                                                                                                                                                                                                                                                                        The result of toStream on a Values.

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

                                                                                                                                                                                                                                                                                          A stream over the iterator.

                                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                                          Instances For

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

                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                              instance Std.RBMap.instToStreamValuesStream {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                              • Std.RBMap.instToStreamValuesStream = { toStream := Std.RBMap.Values.toStream }
                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                              • Std.RBMap.instStreamStream_1 = { next? := Std.RBMap.Values.Stream.next? }
                                                                                                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                                                                                                              def Std.RBMap.isEmpty {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                                              Std.RBMap α β cmpBool

                                                                                                                                                                                                                                                                                              O(1). Is the tree empty?

                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                              • Std.RBMap.isEmpty = Std.RBSet.isEmpty
                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                                                                def Std.RBMap.toList {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                                                Std.RBMap α β cmpList (α × β)

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

                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                • Std.RBMap.toList = Std.RBSet.toList
                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                                                                  def Std.RBMap.min? {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                                                  Std.RBMap α β cmpOption (α × β)

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

                                                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                                                  • Std.RBMap.min? = Std.RBSet.min?
                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                                                                                                    def Std.RBMap.max? {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                                                    Std.RBMap α β cmpOption (α × β)

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

                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                    • Std.RBMap.max? = Std.RBSet.max?
                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                      @[deprecated Std.RBMap.min?]
                                                                                                                                                                                                                                                                                                      def Std.RBMap.min {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                                                      Std.RBMap α β cmpOption (α × β)

                                                                                                                                                                                                                                                                                                      Alias of Std.RBMap.min?.


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

                                                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                        @[deprecated Std.RBMap.max?]
                                                                                                                                                                                                                                                                                                        def Std.RBMap.max {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                                                        Std.RBMap α β cmpOption (α × β)

                                                                                                                                                                                                                                                                                                        Alias of Std.RBMap.max?.


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

                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                          instance Std.RBMap.instReprRBMap {α : Type u} {β : Type v} {cmp : ααOrdering} [Repr α] [Repr β] :
                                                                                                                                                                                                                                                                                                          Repr (Std.RBMap α β cmp)
                                                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                                                          @[inline]
                                                                                                                                                                                                                                                                                                          def Std.RBMap.insert {α : Type u} {β : Type v} {cmp : ααOrdering} (t : Std.RBMap α β cmp) (k : α) (v : β) :
                                                                                                                                                                                                                                                                                                          Std.RBMap α β cmp

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                                                                                                        def Std.RBMap.lowerBound? {α : Type u} {β : Type v} {cmp : ααOrdering} (t : Std.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.

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

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

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

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

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

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

                                                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                                                                                                def Std.RBMap.all₂ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {cmpα : ααOrdering} {cmpγ : γγOrdering} (R : α × βγ × δBool) (t₁ : Std.RBMap α β cmpα) (t₂ : Std.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.

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

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

                                                                                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                    instance Std.RBMap.instBEqRBMap {α : Type u} {β : Type v} {cmp : ααOrdering} [BEq α] [BEq β] :
                                                                                                                                                                                                                                                                                                                                    BEq (Std.RBMap α β cmp)

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

                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                    def Std.RBMap.size {α : Type u} {β : Type v} {cmp : ααOrdering} :
                                                                                                                                                                                                                                                                                                                                    Std.RBMap α β cmpNat

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

                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                    • Std.RBMap.size = Std.RBSet.size
                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                                                                                                      def Std.RBMap.min! {α : Type u} {β : Type v} {cmp : ααOrdering} [Inhabited α] [Inhabited β] :
                                                                                                                                                                                                                                                                                                                                      Std.RBMap α β cmpα × β

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

                                                                                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                                                                                      • Std.RBMap.min! = Std.RBSet.min!
                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                                                                                                                        def Std.RBMap.max! {α : Type u} {β : Type v} {cmp : ααOrdering} [Inhabited α] [Inhabited β] :
                                                                                                                                                                                                                                                                                                                                        Std.RBMap α β cmpα × β

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

                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                        • Std.RBMap.max! = Std.RBSet.max!
                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                          @[inline]
                                                                                                                                                                                                                                                                                                                                          def Std.RBMap.find! {α : Type u} {β : Type v} {cmp : ααOrdering} [Inhabited β] (t : Std.RBMap α β cmp) (k : α) :
                                                                                                                                                                                                                                                                                                                                          β

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

                                                                                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                            def Std.RBMap.mergeWith {α : Type u} {β : Type v} {cmp : ααOrdering} (mergeFn : αβββ) (t₁ : Std.RBMap α β cmp) (t₂ : Std.RBMap α β cmp) :
                                                                                                                                                                                                                                                                                                                                            Std.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.

                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                              def Std.RBMap.intersectWith {α : Type u} {β : Type v} {cmp : ααOrdering} {γ : Type u_1} {δ : Type u_2} (mergeFn : αβγδ) (t₁ : Std.RBMap α β cmp) (t₂ : Std.RBMap α γ cmp) :
                                                                                                                                                                                                                                                                                                                                              Std.RBMap α δ cmp

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

                                                                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                def Std.RBMap.filter {α : Type u} {β : Type v} {cmp : ααOrdering} (t : Std.RBMap α β cmp) (p : αβBool) :
                                                                                                                                                                                                                                                                                                                                                Std.RBMap α β cmp

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

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

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

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

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

                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                    Instances For