WPILibC++  2019.3.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
wpi::StringMap< ValueTy > 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 <StringMap.h>

Inheritance diagram for wpi::StringMap< ValueTy >:
wpi::StringMapImpl

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 (unsigned InitialSize)
 
 StringMap (std::initializer_list< std::pair< StringRef, ValueTy >> List)
 
 StringMap (StringMap &&RHS)
 
 StringMap (const StringMap &RHS)
 
StringMapoperator= (StringMap RHS)
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
iterator_range
< StringMapKeyIterator
< ValueTy > > 
keys () const
 
iterator find (StringRef Key)
 
const_iterator find (StringRef Key) const
 
ValueTy lookup (StringRef Key) const
 lookup - Return the entry for the specified key, or a default constructed value if no such entry exists. More...
 
ValueTy & operator[] (StringRef Key)
 Lookup the ValueTy for the Key, or create a default constructed value if the key is not in the map. More...
 
size_type count (StringRef Key) const
 count - Return 1 if the element is in the map, 0 otherwise.
 
bool insert (MapEntryTy *KeyValue)
 insert - Insert the specified key/value pair into the map. More...
 
std::pair< iterator, bool > insert (std::pair< StringRef, ValueTy > KV)
 insert - Inserts the specified key/value pair into the map if the key isn't already in the map. More...
 
template<typename... ArgsTy>
std::pair< iterator, bool > emplace_second (StringRef Key, ArgsTy &&...Args)
 
template<typename... ArgsTy>
std::pair< iterator, bool > try_emplace (StringRef 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 (StringRef Key)
 
- 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 ()
 
- Protected Member Functions inherited from wpi::StringMapImpl
 StringMapImpl (unsigned itemSize)
 
 StringMapImpl (StringMapImpl &&RHS)
 
 StringMapImpl (unsigned InitSize, unsigned ItemSize)
 
unsigned RehashTable (unsigned BucketNo=0)
 
unsigned LookupBucketFor (StringRef Key)
 LookupBucketFor - Look up the bucket that the specified string should end up in. More...
 
int FindKey (StringRef 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 (StringRef 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>
class wpi::StringMap< ValueTy >

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 Function Documentation

template<typename ValueTy>
bool wpi::StringMap< ValueTy >::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.

template<typename ValueTy>
std::pair<iterator, bool> wpi::StringMap< ValueTy >::insert ( std::pair< StringRef, 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.

template<typename ValueTy>
ValueTy wpi::StringMap< ValueTy >::lookup ( StringRef  Key) const
inline

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

template<typename ValueTy>
ValueTy& wpi::StringMap< ValueTy >::operator[] ( StringRef  Key)
inline

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

template<typename ValueTy>
void wpi::StringMap< ValueTy >::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.

template<typename ValueTy>
template<typename... ArgsTy>
std::pair<iterator, bool> wpi::StringMap< ValueTy >::try_emplace ( StringRef  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: