WPILibC++ 2024.3.2
wpi::StringMap< ValueTy, AllocatorTy > Class Template Reference

StringMap - This is an unconventional map that is specialized for handling keys that are "strings", which are basically ranges of bytes. More...

#include </home/runner/work/allwpilib/allwpilib/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMap.h>

Inheritance diagram for wpi::StringMap< ValueTy, AllocatorTy >:
wpi::StringMapImpl wpi::detail::AllocatorHolder< MallocAllocator >

Public Types

using MapEntryTy = StringMapEntry< ValueTy >
 
using key_type = const char *
 
using mapped_type = ValueTy
 
using value_type = StringMapEntry< ValueTy >
 
using size_type = size_t
 
using const_iterator = StringMapConstIterator< ValueTy >
 
using iterator = StringMapIterator< ValueTy >
 

Public Member Functions

 StringMap ()
 
 StringMap (unsigned InitialSize)
 
 StringMap (AllocatorTy A)
 
 StringMap (unsigned InitialSize, AllocatorTy A)
 
 StringMap (std::initializer_list< std::pair< std::string_view, ValueTy > > List)
 
 StringMap (StringMap &&RHS)
 
 StringMap (const StringMap &RHS)
 
StringMapoperator= (StringMap RHS)
 
 ~StringMap ()
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
iterator_range< StringMapKeyIterator< ValueTy > > keys () const
 
iterator find (std::string_view Key)
 
const_iterator find (std::string_view Key) const
 
ValueTy lookup (std::string_view Key) const
 lookup - Return the entry for the specified key, or a default constructed value if no such entry exists. More...
 
const ValueTy & at (std::string_view Val) const
 at - Return the entry for the specified key, or abort if no such entry exists. More...
 
ValueTy & operator[] (std::string_view Key)
 Lookup the ValueTy for the Key, or create a default constructed value if the key is not in the map. More...
 
bool contains (std::string_view Key) const
 contains - Return true if the element is in the map, false otherwise. More...
 
size_type count (std::string_view Key) const
 count - Return 1 if the element is in the map, 0 otherwise. More...
 
template<typename InputTy >
size_type count (const StringMapEntry< InputTy > &MapEntry) const
 
bool operator== (const StringMap &RHS) const
 equal - check whether both of the containers are equal. More...
 
bool operator!= (const StringMap &RHS) const
 
bool insert (MapEntryTy *KeyValue)
 insert - Insert the specified key/value pair into the map. More...
 
std::pair< iterator, bool > insert (std::pair< std::string_view, ValueTy > KV)
 insert - Inserts the specified key/value pair into the map if the key isn't already in the map. More...
 
template<typename InputIt >
void insert (InputIt First, InputIt Last)
 Inserts elements from range [first, last). More...
 
void insert (std::initializer_list< std::pair< std::string_view, ValueTy > > List)
 Inserts elements from initializer list ilist. More...
 
template<typename V >
std::pair< iterator, bool > insert_or_assign (std::string_view Key, V &&Val)
 Inserts an element or assigns to the current element if the key already exists. More...
 
template<typename... ArgsTy>
std::pair< iterator, bool > try_emplace (std::string_view Key, ArgsTy &&...Args)
 Emplace a new element for the specified key into the map if the key isn't already in the map. More...
 
void clear ()
 
void remove (MapEntryTy *KeyValue)
 remove - Remove the specified key/value pair from the map, but do not erase it. More...
 
void erase (iterator I)
 
bool erase (std::string_view Key)
 
Alloc & getAllocator ()
 
const Alloc & getAllocator () const
 
- Public Member Functions inherited from wpi::StringMapImpl
unsigned getNumBuckets () const
 
unsigned getNumItems () const
 
bool empty () const
 
unsigned size () const
 
void swap (StringMapImpl &Other)
 

Additional Inherited Members

- Static Public Member Functions inherited from wpi::StringMapImpl
static StringMapEntryBasegetTombstoneVal ()
 
- Static Public Attributes inherited from wpi::StringMapImpl
static constexpr uintptr_t TombstoneIntVal
 
- Protected Member Functions inherited from wpi::StringMapImpl
 StringMapImpl (unsigned itemSize)
 
 StringMapImpl (StringMapImpl &&RHS) noexcept
 
 StringMapImpl (unsigned InitSize, unsigned ItemSize)
 
unsigned RehashTable (unsigned BucketNo=0)
 
unsigned LookupBucketFor (std::string_view Key)
 LookupBucketFor - Look up the bucket that the specified string should end up in. More...
 
int FindKey (std::string_view Key) const
 FindKey - Look up the bucket that contains the specified key. More...
 
void RemoveKey (StringMapEntryBase *V)
 RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it. More...
 
StringMapEntryBaseRemoveKey (std::string_view Key)
 RemoveKey - Remove the StringMapEntry for the specified key from the table, returning it. More...
 
void init (unsigned Size)
 Allocate the table with the specified number of buckets and otherwise setup the map as empty. More...
 
- Protected Attributes inherited from wpi::StringMapImpl
StringMapEntryBase ** TheTable = nullptr
 
unsigned NumBuckets = 0
 
unsigned NumItems = 0
 
unsigned NumTombstones = 0
 
unsigned ItemSize
 

Detailed Description

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

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

Member Typedef Documentation

◆ const_iterator

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
using wpi::StringMap< ValueTy, AllocatorTy >::const_iterator = StringMapConstIterator<ValueTy>

◆ iterator

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
using wpi::StringMap< ValueTy, AllocatorTy >::iterator = StringMapIterator<ValueTy>

◆ key_type

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
using wpi::StringMap< ValueTy, AllocatorTy >::key_type = const char *

◆ MapEntryTy

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
using wpi::StringMap< ValueTy, AllocatorTy >::MapEntryTy = StringMapEntry<ValueTy>

◆ mapped_type

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
using wpi::StringMap< ValueTy, AllocatorTy >::mapped_type = ValueTy

◆ size_type

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
using wpi::StringMap< ValueTy, AllocatorTy >::size_type = size_t

◆ value_type

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
using wpi::StringMap< ValueTy, AllocatorTy >::value_type = StringMapEntry<ValueTy>

Constructor & Destructor Documentation

◆ StringMap() [1/7]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
wpi::StringMap< ValueTy, AllocatorTy >::StringMap ( )
inline

◆ StringMap() [2/7]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
wpi::StringMap< ValueTy, AllocatorTy >::StringMap ( unsigned  InitialSize)
inlineexplicit

◆ StringMap() [3/7]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
wpi::StringMap< ValueTy, AllocatorTy >::StringMap ( AllocatorTy  A)
inlineexplicit

◆ StringMap() [4/7]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
wpi::StringMap< ValueTy, AllocatorTy >::StringMap ( unsigned  InitialSize,
AllocatorTy  A 
)
inline

◆ StringMap() [5/7]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
wpi::StringMap< ValueTy, AllocatorTy >::StringMap ( std::initializer_list< std::pair< std::string_view, ValueTy > >  List)
inline

◆ StringMap() [6/7]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
wpi::StringMap< ValueTy, AllocatorTy >::StringMap ( StringMap< ValueTy, AllocatorTy > &&  RHS)
inline

◆ StringMap() [7/7]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
wpi::StringMap< ValueTy, AllocatorTy >::StringMap ( const StringMap< ValueTy, AllocatorTy > &  RHS)
inline

◆ ~StringMap()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
wpi::StringMap< ValueTy, AllocatorTy >::~StringMap ( )
inline

Member Function Documentation

◆ at()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
const ValueTy & wpi::StringMap< ValueTy, AllocatorTy >::at ( std::string_view  Val) const
inline

at - Return the entry for the specified key, or abort if no such entry exists.

◆ begin() [1/2]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
iterator wpi::StringMap< ValueTy, AllocatorTy >::begin ( )
inline

◆ begin() [2/2]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
const_iterator wpi::StringMap< ValueTy, AllocatorTy >::begin ( ) const
inline

◆ clear()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
void wpi::StringMap< ValueTy, AllocatorTy >::clear ( )
inline

◆ contains()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
bool wpi::StringMap< ValueTy, AllocatorTy >::contains ( std::string_view  Key) const
inline

contains - Return true if the element is in the map, false otherwise.

◆ count() [1/2]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
template<typename InputTy >
size_type wpi::StringMap< ValueTy, AllocatorTy >::count ( const StringMapEntry< InputTy > &  MapEntry) const
inline

◆ count() [2/2]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
size_type wpi::StringMap< ValueTy, AllocatorTy >::count ( std::string_view  Key) const
inline

count - Return 1 if the element is in the map, 0 otherwise.

◆ end() [1/2]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
iterator wpi::StringMap< ValueTy, AllocatorTy >::end ( )
inline

◆ end() [2/2]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
const_iterator wpi::StringMap< ValueTy, AllocatorTy >::end ( ) const
inline

◆ erase() [1/2]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
void wpi::StringMap< ValueTy, AllocatorTy >::erase ( iterator  I)
inline

◆ erase() [2/2]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
bool wpi::StringMap< ValueTy, AllocatorTy >::erase ( std::string_view  Key)
inline

◆ find() [1/2]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
iterator wpi::StringMap< ValueTy, AllocatorTy >::find ( std::string_view  Key)
inline

◆ find() [2/2]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
const_iterator wpi::StringMap< ValueTy, AllocatorTy >::find ( std::string_view  Key) const
inline

◆ getAllocator() [1/2]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
Alloc & wpi::detail::AllocatorHolder< Alloc >::getAllocator ( )
inline

◆ getAllocator() [2/2]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
const Alloc & wpi::detail::AllocatorHolder< Alloc >::getAllocator ( ) const
inline

◆ insert() [1/4]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
template<typename InputIt >
void wpi::StringMap< ValueTy, AllocatorTy >::insert ( InputIt  First,
InputIt  Last 
)
inline

Inserts elements from range [first, last).

If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted .

◆ insert() [2/4]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
bool wpi::StringMap< ValueTy, AllocatorTy >::insert ( MapEntryTy KeyValue)
inline

insert - Insert the specified key/value pair into the map.

If the key already exists in the map, return false and ignore the request, otherwise insert it and return true.

◆ insert() [3/4]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
void wpi::StringMap< ValueTy, AllocatorTy >::insert ( std::initializer_list< std::pair< std::string_view, ValueTy > >  List)
inline

Inserts elements from initializer list ilist.

If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted

◆ insert() [4/4]

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
std::pair< iterator, bool > wpi::StringMap< ValueTy, AllocatorTy >::insert ( std::pair< std::string_view, ValueTy >  KV)
inline

insert - Inserts the specified key/value pair into the map if the key isn't already in the map.

The bool component of the returned pair is true if and only if the insertion takes place, and the iterator component of the pair points to the element with key equivalent to the key of the pair.

◆ insert_or_assign()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
template<typename V >
std::pair< iterator, bool > wpi::StringMap< ValueTy, AllocatorTy >::insert_or_assign ( std::string_view  Key,
V &&  Val 
)
inline

Inserts an element or assigns to the current element if the key already exists.

The return type is the same as try_emplace.

◆ keys()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
iterator_range< StringMapKeyIterator< ValueTy > > wpi::StringMap< ValueTy, AllocatorTy >::keys ( ) const
inline

◆ lookup()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
ValueTy wpi::StringMap< ValueTy, AllocatorTy >::lookup ( std::string_view  Key) const
inline

lookup - Return the entry for the specified key, or a default constructed value if no such entry exists.

◆ operator!=()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
bool wpi::StringMap< ValueTy, AllocatorTy >::operator!= ( const StringMap< ValueTy, AllocatorTy > &  RHS) const
inline

◆ operator=()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
StringMap & wpi::StringMap< ValueTy, AllocatorTy >::operator= ( StringMap< ValueTy, AllocatorTy >  RHS)
inline

◆ operator==()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
bool wpi::StringMap< ValueTy, AllocatorTy >::operator== ( const StringMap< ValueTy, AllocatorTy > &  RHS) const
inline

equal - check whether both of the containers are equal.

◆ operator[]()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
ValueTy & wpi::StringMap< ValueTy, AllocatorTy >::operator[] ( std::string_view  Key)
inline

Lookup the ValueTy for the Key, or create a default constructed value if the key is not in the map.

◆ remove()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
void wpi::StringMap< ValueTy, AllocatorTy >::remove ( MapEntryTy KeyValue)
inline

remove - Remove the specified key/value pair from the map, but do not erase it.

This aborts if the key is not in the map.

◆ try_emplace()

template<typename ValueTy , typename AllocatorTy = MallocAllocator>
template<typename... ArgsTy>
std::pair< iterator, bool > wpi::StringMap< ValueTy, AllocatorTy >::try_emplace ( std::string_view  Key,
ArgsTy &&...  Args 
)
inline

Emplace a new element for the specified key into the map if the key isn't already in the map.

The bool component of the returned pair is true if and only if the insertion takes place, and the iterator component of the pair points to the element with key equivalent to the key of the pair.


The documentation for this class was generated from the following file: