libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
grpsubgroupset.cpp
Go to the documentation of this file.
1
2/*******************************************************************************
3 * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
4 *
5 * This file is part of the PAPPSOms++ library.
6 *
7 * PAPPSOms++ is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * PAPPSOms++ is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Contributors:
21 * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
22 *implementation
23 ******************************************************************************/
24
25#include "grpsubgroupset.h"
26
27namespace pappso
28{
29
33
35 : m_grpSubGroupPtrList(other.m_grpSubGroupPtrList)
36{
37}
38
42
43
44void
46{
47
48 std::list<GrpSubGroup *>::iterator it(m_grpSubGroupPtrList.begin());
49 std::list<GrpSubGroup *>::iterator itEnd(m_grpSubGroupPtrList.end());
50 std::list<GrpSubGroup *>::const_iterator itIn(
51 other.m_grpSubGroupPtrList.begin());
52 std::list<GrpSubGroup *>::const_iterator itInEnd(
53 other.m_grpSubGroupPtrList.end());
54
55 while((itIn != itInEnd) && (it != itEnd))
56 {
57 if(*itIn < *it)
58 {
59 it++;
60 continue;
61 }
62 if(*itIn > *it)
63 {
64 it = m_grpSubGroupPtrList.insert(it, *itIn);
65 it++;
66 itIn++;
67 continue;
68 }
69 if(*itIn == *it)
70 {
71 itIn++;
72 it++;
73 }
74 }
75 while(itIn != itInEnd)
76 {
77 m_grpSubGroupPtrList.push_back(*itIn);
78 itIn++;
79 }
80}
81
82void
84{
85 m_grpSubGroupPtrList.remove(p_remove_sub_group);
86}
87
88bool
90{
91
92 std::list<GrpSubGroup *>::const_iterator it(m_grpSubGroupPtrList.begin()),
93 itEnd(m_grpSubGroupPtrList.end());
94
95
96 while(it != itEnd)
97 {
98 if(p_sub_group == *it)
99 {
100 // this subgroup is already in list
101 return true;
102 }
103 if(p_sub_group > *it)
104 {
105 return false;
106 }
107 it++;
108 }
109 return false;
110}
111void
113{
114
115 std::list<GrpSubGroup *>::iterator it(m_grpSubGroupPtrList.begin()),
116 itEnd(m_grpSubGroupPtrList.end());
117
118
119 while(it != itEnd)
120 {
121 if(p_add_sub_group == *it)
122 {
123 // this subgroup is already in list
124 return;
125 }
126 if(p_add_sub_group > *it)
127 {
128 it = m_grpSubGroupPtrList.insert(it, p_add_sub_group);
129 return;
130 }
131 it++;
132 }
133 m_grpSubGroupPtrList.push_back(p_add_sub_group);
134}
135
136
137const QString
139{
140 QString infos;
141 std::list<GrpSubGroup *>::const_iterator it(m_grpSubGroupPtrList.begin()),
142 itEnd(m_grpSubGroupPtrList.end());
143
144
145 while(it != itEnd)
146 {
147 infos.append((*it)->getFirstAccession() + " " +
148 QString("0x%1").arg(
149 (quintptr)*it, QT_POINTER_SIZE * 2, 16, QChar('0')) +
150 "\n");
151 it++;
152 }
153
154 return infos;
155}
156
157} // namespace pappso
void remove(GrpSubGroup *p_remove_sub_group)
bool contains(GrpSubGroup *get) const
void add(GrpSubGroup *p_add_sub_group)
const QString printInfos() const
void addAll(const GrpSubGroupSet &other)
std::list< GrpSubGroup * > m_grpSubGroupPtrList
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39