Logo Search packages:      
Sourcecode: pan version File versions  Download package

pan::Quark Class Reference
[General Utilities]

#include <quark.h>

List of all members.

Detailed Description

A two-way association between a string and integral type identifier.

Quarks make good keys because comparision operations can be done on the integral type instead of with costly strcmps.

In X11 and Gtk+ implementations, the string+integral mapping is permanent. However pan::Quark frees its copy of the mapped string when the last corresponding pan::Quark is destroyed. This way Quarks can be used even on large, transient sets of data (such as Message-IDs) without leaking the keys.

There is, obviously, a tradeoff involved: hashing strings can be expensive, and the refcounted hashtable of strings has its own memory overhead. So while strings that are likely to be duplicated or used as keys -- message-ids, author names, and group names spring to mind -- they're less appropriate for temporary, unique data.

Definition at line 66 of file quark.h.

Public Member Functions

const char * c_str () const
void clear ()
bool empty () const
 operator const char * () const
bool operator! () const
bool operator!= (const Quark &q) const
bool operator!= (const StringView &that) const
bool operator!= (const char *that) const
bool operator< (const Quark &q) const
Quarkoperator= (const Quark &q)
bool operator== (const Quark &q) const
bool operator== (const StringView &that) const
bool operator== (const char *that) const
 Quark (const Quark &q)
 Quark (const StringView &p)
 Quark (const char *s)
 Quark (const std::string &s)
std::string to_string () const
const StringView to_view () const

Static Public Member Functions

static void dump (std::ostream &)
static unsigned long size ()

Private Types

typedef std::set< Impl > lookup_t

Private Member Functions

void unref ()

Static Private Member Functions

static Impl * init (const StringView &s)

Private Attributes

Impl * impl

Static Private Attributes

static lookup_t _lookup


struct  Impl
struct  StringViewHash

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

Generated by  Doxygen 1.6.0   Back to index