Map specialized for string keys with efficient allocation and hashing.

Synopsis

Declared in <llvm/ADT/StringMap.h>

template<
    typename ValueTy,
    typename AllocatorTy = MallocAllocator>
class StringMap
    : public StringMapImpl

Description

This is an unconventional map that is specialized for handling keys that are "strings", which are basically ranges of bytes. This does some funky memory allocation and hashing things to make it extremely efficient, storing the string data after the value in the map.

Base Classes

Name

Description

StringMapImpl

StringMapImpl ‐ This is the base class of StringMap that is shared among all of its instantiations.

Types

Name

Description

HandleBase

Empty stub of HandleBase used when ABI‐breaking checks are disabled.

Type Aliases

Name

Description

MapEntryTy

Entry type storing a key and mapped value together.

const_iterator

Const iterator over map entries.

iterator

Mutable iterator over map entries.

key_type

Key type exposed for STL compatibility (internally a C string pointer).

mapped_type

Mapped value type.

size_type

Unsigned type used for sizes.

value_type

Entry type combining key and value.

Member Functions

Name

Description

StringMap [constructor]

Constructors

~StringMap [destructor]

Destroy all entries and free the table.

operator=

Copy‐assign by swapping with a copy of RHS.

at

Return a const reference to the value for Val, aborting if absent.

begin

begin overloads

clear

Remove all entries from the map.

contains

Return true if Key is present in the map.

count

count overloads

empty

Return true if the map contains no entries.

end

end overloads

erase

erase overloads

find

find overloads

getNumBuckets

Return the number of allocated hash buckets.

getNumItems

Return the number of live entries.

incrementEpoch

No‐op when ABI‐breaking checks are disabled.

insert

insert overloads

insert_or_assign

Insert or assign a mapped value for Key.

keys

Return a range that yields each key as a StringRef.

lookup

Return the value for Key, or a default‐constructed value if absent.

operator[]

Return a reference to the value for Key, inserting a default if absent.

remove

Remove KeyValue from the map without destroying it.

remove_if

Remove every entry for which Pred returns true.

size

Return the number of live entries.

swap

Exchange the contents of this map with Other.

try_emplace

Emplace a value for Key if the key is not already present.

try_emplace_with_hash

Emplace a value for Key using a precomputed hash if absent.

operator==

Return true if this map and RHS have the same keys and values.

operator!=

Return true if the maps differ in keys or values.

Static Member Functions

Name

Description

hash

Return the hash value used for Key.

Using Declarations

Name

Description

getAllocator

Return the allocator used by this map.

Protected Member Functions

Name

Description

FindKey

FindKey overloads

LookupBucketFor

LookupBucketFor overloads

RehashTable

Grow and rehash the table; return the new bucket for BucketNo.

RemoveKey

RemoveKey overloads

buckets

Return a range over the raw bucket pointer array.

init

Allocate the table with the specified number of buckets and otherwise setup the map as empty.

removeBucket

Remove the entry pointer at the given (live) bucket without destroying the entry, and close the hole via Algorithm R backward shifting.

Protected Data Members

Name

Description

ItemSize

Size in bytes of each StringMapEntry specialization.

NumBuckets

Number of hash buckets currently allocated.

NumItems

Number of live key/value entries in the map.

TheTable

Hash table of entry pointers; null slots are empty probe holes.

Non-Member Functions

Name

Description

getCPUDefaultTargetFeatures

Returns the default enabled features for CPU, or nullopt if unknown.

ARM::PrintSupportedExtensions

Print a table of ‐march extensions that have a non‐empty feature string.

DWARFYAML::emitDebugSections

Parse YAMLString and emit all non‐empty DWARF sections it describes.

PPC::getPPCDefaultTargetFeatures

Return the default target features for PowerPC CPU CPUName on triple T.

orc::addDefaultBootstrapValuesForHostProcess

Add default bootstrap values for JIT execution in the host process.

sys::getHostCPUFeatures

getHostCPUFeatures ‐ Get the LLVM names for the host CPU features.

Derived Classes

Name

Description

StringSet

StringSet ‐ A wrapper for StringMap that provides set‐like functionality.

Created with MrDocs