LOOS  v2.3.2
UniqueStrings.hpp
1 /*
2  This file is part of LOOS.
3 
4  LOOS (Lightweight Object-Oriented Structure library)
5  Copyright (c) 2008, Tod D. Romo, Alan Grossfield
6  Department of Biochemistry and Biophysics
7  School of Medicine & Dentistry, University of Rochester
8 
9  This package (LOOS) is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation under version 3 of the License.
12 
13  This package is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 
23 
24 /*
25  ***WARNING******WARNING******WARNING******WARNING******WARNING******WARNING***
26 
27  THIS CLASS IS NOW DEPRECATED AND WILL BE REMOVED IN A FUTURE RELEASE OF LOOS
28 
29  ***WARNING******WARNING******WARNING******WARNING******WARNING******WARNING***
30 */
31 
32 #if !defined(LOOS_UNIQUESTRINGS_HPP)
33 #define LOOS_UNIQUESTRINGS_HPP
34 
35 
36 #include <string>
37 #include <ext/slist>
38 
39 
40 namespace loos {
41 
43 
47  class UniqueStrings {
48  public:
49 
51  void add(const std::string& s) {
52  if (find(s) < 0)
53  uniques.push_front(s);
54  }
55 
57  int size(void) const { return(uniques.size()); }
58 
60  __gnu_cxx::slist<std::string> strings(void) const { return(uniques); }
61 
63 
66  int find(const std::string& s) {
67  int j = 0;
68  __gnu_cxx::slist<std::string>::const_iterator i;
69  for (i = uniques.begin(); i != uniques.end(); i++, j++)
70  if (*i == s)
71  return(j);
72  return(-1);
73  }
74 
75  private:
76  __gnu_cxx::slist<std::string> uniques;
77  };
78 
79 }
80 #endif
void add(const std::string &s)
Adds a string to the unique string list.
int find(const std::string &s)
Checks to see if we've encountered this string before...
__gnu_cxx::slist< std::string > strings(void) const
Returns the raw slist of strings...
int size(void) const
Number of unique strings found...
Class for uniquifying strings...
Namespace for most things not already encapsulated within a class.