COPASI API  4.16.103
IdList.h
Go to the documentation of this file.
1 /**
2  * @cond doxygen-libsbml-internal
3  *
4  * @file IdList.h
5  * @brief Maintains a list of SIds. Useful for finding cycles.
6  * @author Ben Bornstein
7  *
8  * <!--------------------------------------------------------------------------
9  * This file is part of libSBML. Please visit http://sbml.org for more
10  * information about SBML, and the latest version of libSBML.
11  *
12  * Copyright (C) 2009-2013 jointly by the following organizations:
13  * 1. California Institute of Technology, Pasadena, CA, USA
14  * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK
15  *
16  * Copyright (C) 2006-2008 by the California Institute of Technology,
17  * Pasadena, CA, USA
18  *
19  * Copyright (C) 2002-2005 jointly by the following organizations:
20  * 1. California Institute of Technology, Pasadena, CA, USA
21  * 2. Japan Science and Technology Agency, Japan
22  *
23  * This library is free software; you can redistribute it and/or modify it
24  * under the terms of the GNU Lesser General Public License as published by
25  * the Free Software Foundation. A copy of the license agreement is provided
26  * in the file named "LICENSE.txt" included with this software distribution
27  * and also available online as http://sbml.org/software/libsbml/license.html
28  * ---------------------------------------------------------------------- -->*/
29 
30 #ifndef IdList_h
31 #define IdList_h
32 
33 
34 #ifdef __cplusplus
35 
36 
37 #include <string>
38 #include <vector>
39 #include <sbml/common/libsbml-namespace.h>
40 
41 LIBSBML_CPP_NAMESPACE_BEGIN
42 
43 class IdList
44 {
45 public:
46 
47  typedef std::vector<std::string>::iterator iterator;
48  typedef std::vector<std::string>::const_iterator const_iterator;
49 
50  /**
51  * Appends id to the list of ids.
52  */
53  void append (const std::string id) { mIds.push_back(id); }
54 
55  /**
56  * @return true if id is already in this IdList, false otherwise.
57  */
58  bool contains (const std::string id) const;
59 
60  /**
61  * Removes all ids in this IdList before the given @p id.
62  */
63  void removeIdsBefore (const std::string id);
64 
65  /**
66  * @return the number of ids in this IdList.
67  */
68  unsigned int size () const { return (unsigned int)mIds.size(); }
69 
70  /**
71  * @return an iterator to the beginning of this IdList.
72  */
73  std::vector<std::string>::const_iterator begin () const
74  {
75  return mIds.begin();
76  }
77 
78  /**
79  * @return an iterator to the end of this IdList.
80  */
81  std::vector<std::string>::const_iterator end () const
82  {
83  return mIds.end();
84  }
85 
86 
87  void clear() { mIds.clear(); }
88 
89  std::string at(int n) { return mIds.at(n); }
90 
91 private:
92 
93  std::vector<std::string> mIds;
94 };
95 
96 LIBSBML_CPP_NAMESPACE_END
97 
98 #endif /* __cplusplus */
99 #endif /* IdList_h */
100 
101 /** @endcond */