Documentation

Std.Internal.Http.Internal.IndexMultiMap

IndexMultiMap #

This module defines a generic IndexMultiMap type that maps keys to multiple values. The implementation stores entries in a flat array for iteration and an index HashMap for fast key lookups. Each key always has at least one associated value.

structure Std.Internal.IndexMultiMap (α : Type u) (β : Type v) [BEq α] [Hashable α] :
Type (max u v)

A structure for managing ordered key-value pairs where each key can have multiple values.

Instances For
    @[implicit_reducible]
    instance Std.Internal.instReprIndexMultiMap {α✝ : Type u_1} {β✝ : Type u_2} {inst✝ : BEq α✝} {inst✝¹ : Hashable α✝} [Repr α✝] [Repr β✝] :
    Repr (IndexMultiMap α✝ β✝)
    Equations
    def Std.Internal.instReprIndexMultiMap.repr {α✝ : Type u_1} {β✝ : Type u_2} {inst✝ : BEq α✝} {inst✝¹ : Hashable α✝} [Repr α✝] [Repr β✝] :
    IndexMultiMap α✝ β✝NatFormat
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[implicit_reducible]
      instance Std.Internal.instInhabitedIndexMultiMap {α : Type u_1} {β : Type u_2} [BEq α] [Hashable α] [Inhabited α] [Inhabited β] :
      Equations
      @[implicit_reducible]
      Equations
      @[implicit_reducible]
      instance Std.Internal.IndexMultiMap.instDecidableMem {α : Type u} {β : Type v} [BEq α] [Hashable α] (key : α) (map : IndexMultiMap α β) :
      Decidable (key map)
      Equations
      @[inline]
      def Std.Internal.IndexMultiMap.getAll {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) (key : α) (h : key map) :

      Retrieves all values for the given key.

      Equations
      Instances For
        @[inline]
        def Std.Internal.IndexMultiMap.get {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) (key : α) (h : key map) :
        β

        Retrieves the first value for the given key.

        Equations
        Instances For
          @[inline]
          def Std.Internal.IndexMultiMap.getAll? {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) (key : α) :

          Retrieves all values for the given key, or none if the key is absent.

          Equations
          Instances For
            @[inline]
            def Std.Internal.IndexMultiMap.get? {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) (key : α) :

            Retrieves the first value for the given key, or none if the key is absent.

            Equations
            Instances For
              @[inline]
              def Std.Internal.IndexMultiMap.hasEntry {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) [BEq β] (key : α) (value : β) :

              Checks if the key-value pair is present in the map.

              Equations
              Instances For
                @[inline]
                def Std.Internal.IndexMultiMap.getLast? {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) (key : α) :

                Retrieves the last value for the given key. Returns none if the key is absent.

                Equations
                Instances For
                  @[inline]
                  def Std.Internal.IndexMultiMap.getD {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) (key : α) (d : β) :
                  β

                  Like get?, but returns a default value if absent.

                  Equations
                  Instances For
                    @[inline]
                    def Std.Internal.IndexMultiMap.get! {α : Type u} {β : Type v} [BEq α] [Hashable α] [Inhabited β] (map : IndexMultiMap α β) (key : α) :
                    β

                    Like get?, but panics if absent.

                    Equations
                    Instances For
                      @[inline]
                      def Std.Internal.IndexMultiMap.insert {α : Type u} {β : Type v} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (map : IndexMultiMap α β) (key : α) (value : β) :

                      Inserts a new key-value pair into the map. If the key already exists, appends the value to existing values.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        @[inline]
                        def Std.Internal.IndexMultiMap.insertMany {α : Type u} {β : Type v} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (map : IndexMultiMap α β) (key : α) (values : Array β) :

                        Inserts multiple values for a given key, appending to any existing values.

                        Equations
                        Instances For
                          def Std.Internal.IndexMultiMap.empty {α : Type u} {β : Type v} [BEq α] [Hashable α] :

                          Creates an empty multimap.

                          Equations
                          Instances For
                            def Std.Internal.IndexMultiMap.ofList {α : Type u} {β : Type v} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (pairs : List (α × β)) :

                            Creates a multimap from a list of key-value pairs.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              @[inline]
                              def Std.Internal.IndexMultiMap.contains {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) (key : α) :

                              Checks if a key exists in the map.

                              Equations
                              Instances For
                                @[inline]
                                def Std.Internal.IndexMultiMap.update {α : Type u} {β : Type v} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (map : IndexMultiMap α β) (key : α) (f : ββ) :

                                Updates all values associated with key by applying f to each one. If the key is absent, returns the map unchanged.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  @[inline]
                                  def Std.Internal.IndexMultiMap.replaceLast {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) (key : α) (value : β) :

                                  Replaces the last value associated with key with value. If the key is absent, returns the map unchanged.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    @[inline]
                                    def Std.Internal.IndexMultiMap.erase {α : Type u} {β : Type v} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (map : IndexMultiMap α β) (key : α) :

                                    Removes a key and all its values from the map. This function rebuilds the entire entries array and indexes map from scratch by filtering out all pairs whose key matches, then re-inserting the survivors.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      @[inline]
                                      def Std.Internal.IndexMultiMap.size {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) :

                                      Gets the number of entries in the map.

                                      Equations
                                      Instances For
                                        @[inline]
                                        def Std.Internal.IndexMultiMap.isEmpty {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) :

                                        Checks if the map is empty.

                                        Equations
                                        Instances For
                                          def Std.Internal.IndexMultiMap.toArray {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) :
                                          Array (α × β)

                                          Converts the multimap to an array of key-value pairs (flattened).

                                          Equations
                                          Instances For
                                            def Std.Internal.IndexMultiMap.toList {α : Type u} {β : Type v} [BEq α] [Hashable α] (map : IndexMultiMap α β) :
                                            List (α × β)

                                            Converts the multimap to a list of key-value pairs (flattened).

                                            Equations
                                            Instances For
                                              def Std.Internal.IndexMultiMap.merge {α : Type u} {β : Type v} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (m1 m2 : IndexMultiMap α β) :

                                              Merges two multimaps, combining values for shared keys.

                                              Equations
                                              Instances For
                                                @[implicit_reducible]
                                                Equations
                                                @[implicit_reducible]
                                                Equations
                                                @[implicit_reducible]
                                                instance Std.Internal.IndexMultiMap.instForInProdOfMonad {α : Type u} {β : Type v} [BEq α] [Hashable α] {m : Type u_1 → Type u_2} [Monad m] :
                                                ForIn m (IndexMultiMap α β) (α × β)
                                                Equations
                                                • One or more equations did not get rendered due to their size.