Documentation

Batteries.Lean.HashSet

Equations
  • Std.HashSet.instSingleton_batteries = { singleton := fun (x : α) => Std.HashSet.empty.insert x }
instance Std.HashSet.instInsert_batteries {α : Type u_1} [BEq α] [Hashable α] :
Equations
  • Std.HashSet.instInsert_batteries = { insert := fun (a : α) (s : Std.HashSet α) => s.insert a }
@[specialize #[]]
def Std.HashSet.anyM {α : Type u_1} [BEq α] [Hashable α] {m : TypeType} [Monad m] (s : Std.HashSet α) (f : αm Bool) :

O(n). Returns true if f returns true for any element of the set.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[inline]
    def Std.HashSet.any {α : Type u_1} [BEq α] [Hashable α] (s : Std.HashSet α) (f : αBool) :

    O(n). Returns true if f returns true for any element of the set.

    Equations
    • s.any f = (s.anyM f).run
    Instances For
      @[specialize #[]]
      def Std.HashSet.allM {α : Type u_1} [BEq α] [Hashable α] {m : TypeType} [Monad m] (s : Std.HashSet α) (f : αm Bool) :

      O(n). Returns true if f returns true for all elements of the set.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        @[inline]
        def Std.HashSet.all {α : Type u_1} [BEq α] [Hashable α] (s : Std.HashSet α) (f : αBool) :

        O(n). Returns true if f returns true for all elements of the set.

        Equations
        • s.all f = (s.allM f).run
        Instances For
          instance Std.HashSet.instBEq_batteries {α : Type u_1} [BEq α] [Hashable α] :
          Equations
          • Std.HashSet.instBEq_batteries = { beq := fun (s t : Std.HashSet α) => (s.all fun (x : α) => t.contains x) && t.all fun (x : α) => s.contains x }
          @[inline]
          def Std.HashSet.insert' {α : Type u_1} [BEq α] [Hashable α] (s : Std.HashSet α) (a : α) :

          O(1) amortized. Similar to insert, but also returns a Boolean flag indicating whether an existing entry has been replaced with a => b.

          Equations
          • s.insert' a = (s.insert a, (s.insert a).size == s.size)
          Instances For
            @[inline]
            def Std.HashSet.ofArray {α : Type u_1} [BEq α] [Hashable α] (as : Array α) :

            O(n). Obtain a HashSet from an array.

            Equations
            Instances For