Adobe Source Libraries  1.43
Public Member Functions | Static Public Member Functions | Friends | List of all members
name_t Struct Reference

Public Member Functions

 name_t (const char *s="")
 
 name_t (const static_name_t &static_name)
 
 operator bool () const
 
const char * c_str () const
 
const char * begin () const
 
const char * end () const
 

Static Public Member Functions

static bool fast_sort (const name_t &x, const name_t &y)
 

Friends

struct std::hash< name_t >
 
std::ostream & operator<< (std::ostream &s, const name_t &name)
 
bool operator== (const name_t &x, const name_t &y)
 
bool operator< (const name_t &x, const name_t &y)
 

Detailed Description

A name is an immutable string literal used for indexing associative containers (e.g., dictionary_t.) It has several performance guarantees that make it a preferred alternative to other string-based key types.

Definition at line 216 of file name.hpp.

Constructor & Destructor Documentation

name_t ( const char *  s = "")
explicit

Definition at line 217 of file name.hpp.

name_t ( const static_name_t static_name)

Implicit conversion constructor from a static_name_t.

Definition at line 222 of file name.hpp.

Member Function Documentation

operator bool ( ) const
explicit
Returns
false iff the instance is equal to the empty string.
Complexity Guarantee(s)
O(1)
const char* c_str ( ) const

Definition at line 253 of file name.hpp.

const char* begin ( ) const

Definition at line 255 of file name.hpp.

const char* end ( ) const

Definition at line 256 of file name.hpp.

static bool fast_sort ( const name_t x,
const name_t y 
)
static

for use with sorting, e.g.:

std::sort(begin(c), end(c), adobe::name_t::fast_sort);

The implicit sort (operator<) is lexicographical ("slow"), whereas fast sort leverages the runtime hash of the name_t to speed things up. The sort order is not guaranteed between processes or DLLs, nor is it guaranteed to be lexicographical. It is only guaranteed to be stable for the lifetime of the process.

Complexity Guarantee(s)
O(1)

Definition at line 272 of file name.hpp.

Friends And Related Function Documentation

friend struct std::hash< name_t >
friend

Definition at line 275 of file name.hpp.

std::ostream& operator<< ( std::ostream &  s,
const name_t name 
)
friend
bool operator== ( const name_t x,
const name_t y 
)
friend
Complexity Guarantee(s)
O(1)

Definition at line 240 of file name.hpp.

bool operator< ( const name_t x,
const name_t y 
)
friend

Lexicographical comparison of two names. For a faster comparsion use name_t::fast_sort.

Complexity Guarantee(s)
O(N)

Definition at line 249 of file name.hpp.