Documentation

Batteries.Data.Array.Merge

def Array.merge {α : Type u_1} (lt : ααBool) (xs ys : Array α) :

O(|xs| + |ys|). Merge arrays xs and ys. If the arrays are sorted according to lt, then the result is sorted as well. If two (or more) elements are equal according to lt, they are preserved.

Instances For
    @[irreducible]
    def Array.merge.go {α : Type u_1} (lt : ααBool) (xs ys acc : Array α) (i j : Nat) :

    Auxiliary definition for merge.

    Instances For
      def Array.mergeDedupWith {α : Type u_1} [ord : Ord α] (xs ys : Array α) (merge : ααα) :

      O(|xs| + |ys|). Merge arrays xs and ys, which must be sorted according to compare and must not contain duplicates. Equal elements are merged using merge. If merge respects the order (i.e. for all x, y, y', z, if x < y < z and x < y' < z then x < merge y y' < z) then the resulting array is again sorted.

      Instances For
        @[irreducible]
        def Array.mergeDedupWith.go {α : Type u_1} [ord : Ord α] (xs ys : Array α) (merge : ααα) (acc : Array α) (i j : Nat) :

        Auxiliary definition for mergeDedupWith.

        Instances For
          @[inline]
          def Array.mergeDedup {α : Type u_1} [ord : Ord α] (xs ys : Array α) :

          O(|xs| + |ys|). Merge arrays xs and ys, which must be sorted according to compare and must not contain duplicates. If an element appears in both xs and ys, only one copy is kept.

          Instances For
            def Array.mergeUnsortedDedup {α : Type u_1} [eq : BEq α] (xs ys : Array α) :

            O(|xs| * |ys|). Merge xs and ys, which do not need to be sorted. Elements which occur in both xs and ys are only added once. If xs and ys do not contain duplicates, then neither does the result.

            Instances For
              @[inline]
              def Array.mergeUnsortedDedup.go {α : Type u_1} [eq : BEq α] (xs ys : Array α) :

              Auxiliary definition for mergeUnsortedDedup.

              Instances For
                def Array.mergeAdjacentDups {α : Type u_1} [eq : BEq α] (f : ααα) (xs : Array α) :

                O(|xs|). Replace each run [x₁, ⋯, xₙ] of equal elements in xs with f ⋯ (f (f x₁ x₂) x₃) ⋯ xₙ.

                Instances For
                  @[irreducible]
                  def Array.mergeAdjacentDups.go {α : Type u_1} [eq : BEq α] (f : ααα) (xs acc : Array α) (i : Nat) (hd : α) :

                  Auxiliary definition for mergeAdjacentDups.

                  Instances For
                    def Array.dedupSorted {α : Type u_1} [eq : BEq α] (xs : Array α) :

                    O(|xs|). Deduplicate a sorted array. The array must be sorted with to an order which agrees with ==, i.e. whenever x == y then compare x y == .eq.

                    Instances For
                      def Array.sortDedup {α : Type u_1} [ord : Ord α] (xs : Array α) :

                      O(|xs| log |xs|). Sort and deduplicate an array.

                      Instances For