Orcus
Public Member Functions | List of all members
orcus::string_pool Class Reference

#include <string_pool.hpp>

Public Member Functions

 string_pool (const string_pool &)=delete
 
string_pooloperator= (const string_pool &)=delete
 
std::pair< std::string_view, bool > intern (std::string_view str)
 
std::vector< std::string_view > get_interned_strings () const
 
void dump () const
 
void clear ()
 
size_t size () const
 
void swap (string_pool &other)
 
void merge (string_pool &other)
 

Detailed Description

Implements string hash map.

Member Function Documentation

◆ get_interned_strings()

std::vector<std::string_view> orcus::string_pool::get_interned_strings ( ) const

Return all interned strings.

Returns
sequence of all interned strings. The sequence will be sorted.

◆ intern()

std::pair<std::string_view, bool> orcus::string_pool::intern ( std::string_view  str)

Intern a string.

Parameters
strstring to intern.
Returns
pair whose first value is the interned string, and the second value specifies whether it is a newly created instance (true) or a reuse of an existing instance (false).

◆ merge()

void orcus::string_pool::merge ( string_pool other)

Merge another string pool instance in. This will not invalidate any string references to the other pool.

The other string pool instance will become empty when this call returns.

Parameters
otherstring pool instance to merge in.