Pol  Revision:4b29d2b
strset.cpp
Go to the documentation of this file.
1 
6 #include "strset.h"
7 
8 #include "stlutil.h"
9 
10 namespace Pol
11 {
12 namespace Clib
13 {
14 bool StringSet::contains( const char* str ) const
15 {
16  return ( strings_.find( str ) != strings_.end() );
17 }
18 
19 void StringSet::add( const char* str )
20 {
21  strings_.insert( str );
22 }
23 void StringSet::remove( const char* str )
24 {
25  strings_.erase( str );
26 }
27 
28 bool StringSet::empty() const
29 {
30  return strings_.empty();
31 }
32 
33 void StringSet::readfrom( const std::string& str )
34 {
35  if ( !str.empty() )
36  {
37  std::string temp;
38  ISTRINGSTREAM is( str );
39  while ( is >> temp )
40  {
41  strings_.insert( temp );
42  }
43  }
44 }
45 
46 std::string StringSet::extract() const
47 {
48  std::string temp;
49  for ( const auto& elem : strings_ )
50  {
51  temp += elem;
52  temp += " ";
53  }
54  return temp;
55 }
56 
58 {
59  return strings_.begin();
60 }
61 
63 {
64  return strings_.end();
65 }
66 
68 {
69  return strings_.begin();
70 }
71 
73 {
74  return strings_.end();
75 }
76 
78 {
79  size_t size = sizeof( StringSet ) + 3 * sizeof( void* );
80  for ( const auto& str : strings_ )
81  {
82  size += str.capacity() + 3 * sizeof( void* );
83  }
84  return size;
85 }
86 }
87 }
std::set< std::string >::iterator iterator
Definition: strset.h:29
void add(const char *str)
Definition: strset.cpp:19
void remove(const char *str)
Definition: strset.cpp:23
void readfrom(const std::string &str)
Definition: strset.cpp:33
iterator end()
Definition: strset.cpp:62
std::string extract() const
Definition: strset.cpp:46
std::set< std::string > strings_
Definition: strset.h:40
std::set< std::string >::const_iterator const_iterator
Definition: strset.h:33
bool contains(const char *str) const
Definition: strset.cpp:14
#define ISTRINGSTREAM
Definition: stlutil.h:73
bool empty() const
Definition: strset.cpp:28
size_t estimatedSize() const
Definition: strset.cpp:77
Definition: berror.cpp:12
iterator begin()
Definition: strset.cpp:57