#include <stringpool.h>
Public Types | |
typedef set< const string *, compare > | PtrSet |
typedef PtrSet::const_iterator | iterator |
Public Methods | |
StringPool () | |
Constructor. More... | |
~StringPool () | |
Destructor. More... | |
const string * | operator() (const string &s) const |
Try to retrieve a string from the pool. More... | |
const string * | operator[] (const string &s) |
Try to retrieve a string from the pool, add it (a copy will be made) if not found. More... | |
void | remove (const string &s) |
Remove a string from the stringpool. More... | |
iterator | begin () const |
iterator | end () const |
size_t | size () const |
Also, comparison can be done on the pointers (much faster).
StringPool pool; string* s = pool["abc"]; if (t = pool("abc")) cout << *t << " already in pool";
Definition at line 19 of file stringpool.h.
|
Definition at line 56 of file stringpool.h. Referenced by size(). |
|
Definition at line 57 of file stringpool.h. |
|
Constructor.
Definition at line 4 of file stringpool.C.
00004 { 00005 } |
|
Destructor.
Definition at line 7 of file stringpool.C.
00007 { 00008 for (PtrSet::const_iterator i=pool_.begin(); i!=pool_.end(); ++i) 00009 delete (*i); 00010 } |
|
Try to retrieve a string from the pool.
Definition at line 13 of file stringpool.C.
00013 { 00014 PtrSet::const_iterator i = pool_.find(&s); 00015 return (i==pool_.end() ? 0 : *i); 00016 } |
|
Try to retrieve a string from the pool, add it (a copy will be made) if not found.
Definition at line 19 of file stringpool.C.
00019 { 00020 return *(pool_.insert(new string(s)).first); 00021 } |
|
Remove a string from the stringpool.
Definition at line 32 of file stringpool.C. Referenced by Index::remove().
00032 { 00033 const string* ps((*this)(s)); 00034 if (ps) 00035 pool_.erase(ps); 00036 } |
|
Definition at line 59 of file stringpool.h. References iterator.
00059 { return pool_.begin(); } |
|
Definition at line 60 of file stringpool.h. References iterator.
00060 { return pool_.end(); } |
|
Definition at line 61 of file stringpool.h. References PtrSet.
00061 { return pool_.size(); } |
textindexer-0.2 | [27 March, 2002] |