a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
LHPC::PointersWithValue< PointerClass, ValueClass > Class Template Reference

#include <PointersWithValue.hpp>

Detailed Description

template<class PointerClass, class ValueClass>
class LHPC::PointersWithValue< PointerClass, ValueClass >

Definition at line 28 of file PointersWithValue.hpp.

Public Member Functions

void addPointer (PointerClass const pointerToAdd)
 
void becomeCopyOf (PointersWithValue< PointerClass, ValueClass > const &copySource)
 
void clearPointers ()
 
bool containsAllAsSubset (std::list< PointerClass > const &sortedList) const
 
bool containsAnyAsSubset (std::list< PointerClass > const &sortedList) const
 
PointersWithValue< PointerClass, ValueClass > * copyAndReturnPointer (PointersWithValue< PointerClass, ValueClass > const &copySource)
 
int getListSize () const
 
ValueClass getPairedValue () const
 
std::list< PointerClass > & getPointerList ()
 
std::list< PointerClass > const & getPointerList () const
 
bool matchesExactly (int const firstCode, int const secondCode, bool(*comparisonFunction)(PointerClass const, int const)) const
 
bool matchesExactly (PointerClass const firstPointer, PointerClass const secondPointer) const
 
bool matchesExactly (std::list< PointerClass > const &sortedList) const
 
void operator= (PointersWithValue< PointerClass, ValueClass > const &copySource)
 
 PointersWithValue ()
 
 PointersWithValue (PointersWithValue< PointerClass, ValueClass > const &copySource)
 
void setPairedValueAndSortPointers (ValueClass const pairedValue)
 
 ~PointersWithValue ()
 

Protected Attributes

ValueClass pairedValue
 
std::list< PointerClass > pointerList
 

Constructor & Destructor Documentation

◆ PointersWithValue() [1/2]

template<class PointerClass , class ValueClass >
LHPC::PointersWithValue< PointerClass, ValueClass >::PointersWithValue
inline

Definition at line 87 of file PointersWithValue.hpp.

87 :
90 {
91 // just an initialization list.
92 }
static double const notANumber
Definition: UsefulStuff.hpp:28
std::list< PointerClass > pointerList

◆ PointersWithValue() [2/2]

template<class PointerClass , class ValueClass >
LHPC::PointersWithValue< PointerClass, ValueClass >::PointersWithValue ( PointersWithValue< PointerClass, ValueClass > const &  copySource)
inline

Definition at line 96 of file PointersWithValue.hpp.

97 :
98 pointerList( copySource.pointerList ),
99 pairedValue( copySource.pairedValue )
100 {
101 // just an initialization list.
102 }

◆ ~PointersWithValue()

template<class PointerClass , class ValueClass >
LHPC::PointersWithValue< PointerClass, ValueClass >::~PointersWithValue
inline

Definition at line 106 of file PointersWithValue.hpp.

107 {
108 // does nothing.
109 }

Member Function Documentation

◆ addPointer()

template<class PointerClass , class ValueClass >
void LHPC::PointersWithValue< PointerClass, ValueClass >::addPointer ( PointerClass const  pointerToAdd)
inline

Definition at line 153 of file PointersWithValue.hpp.

155 {
156 pointerList.push_back( pointerToAdd );
157 }

◆ becomeCopyOf()

template<class PointerClass , class ValueClass >
void LHPC::PointersWithValue< PointerClass, ValueClass >::becomeCopyOf ( PointersWithValue< PointerClass, ValueClass > const &  copySource)
inline

Definition at line 114 of file PointersWithValue.hpp.

116 {
117 this->pointerList = copySource.pointerList;
118 this->pairedValue = copySource.pairedValue;
119 }

◆ clearPointers()

template<class PointerClass , class ValueClass >
void LHPC::PointersWithValue< PointerClass, ValueClass >::clearPointers
inline

Definition at line 168 of file PointersWithValue.hpp.

169 {
170 pointerList.clear();
171 }

◆ containsAllAsSubset()

template<class PointerClass , class ValueClass >
bool LHPC::PointersWithValue< PointerClass, ValueClass >::containsAllAsSubset ( std::list< PointerClass > const &  sortedList) const
inline

Definition at line 255 of file PointersWithValue.hpp.

257 {
258 bool returnBool( false );
259 if( pointerList.size() >= sortedList.size() )
260 {
261 int allowedMismatches( pointerList.size() - sortedList.size() );
262 // the difference in list sizes is the most comparisons that can fail.
263 typename std::list< PointerClass >::const_iterator
264 fromThisSet( pointerList.begin() );
265 typename std::list< PointerClass >::const_iterator
266 toBeCompared( sortedList.begin() );
267 while( ( allowedMismatches >= 0 )
268 &&
269 ( fromThisSet != pointerList.end() ) )
270 {
271 if( *fromThisSet < *toBeCompared )
272 {
273 --allowedMismatches;
274 // note that a comparison failed.
275 }
276 else
277 {
278 if( *fromThisSet == *toBeCompared )
279 {
280 // move on to the next sought pointer, as this one was just found:
281 ++toBeCompared;
282 }
283 else
284 {
285 allowedMismatches = -1;
286 /* otherwise, since the 2 lists are ordered & sortedList is smaller
287 * than pointerList, if *thisSetPointer > *comparisonPointer then
288 * there's no way that all of sortedList can be in pointerList.
289 */
290 }
291 }
292 ++fromThisSet;
293 }
294 if( allowedMismatches >= 0 )
295 {
296 returnBool = true;
297 }
298 }
299 return returnBool;
300 }

◆ containsAnyAsSubset()

template<class PointerClass , class ValueClass >
bool LHPC::PointersWithValue< PointerClass, ValueClass >::containsAnyAsSubset ( std::list< PointerClass > const &  sortedList) const
inline

Definition at line 304 of file PointersWithValue.hpp.

306 {
307 bool returnBool( false );
308 typename std::list< PointerClass >::const_iterator
309 fromThisSet( pointerList.begin() );
310 typename std::list< PointerClass >::const_iterator
311 toBeCompared( sortedList.begin() );
312 /* both lists are sorted, so we walk each iterator along until it catches
313 * up with the other: either it overtakes, & we switch to iterating the
314 * other, or they are equal, in which case we should stop looking, and
315 * return true.
316 */
317 while( !returnBool
318 &&
319 ( fromThisSet != pointerList.end() )
320 &&
321 ( toBeCompared != sortedList.end() ) )
322 {
323 if( *fromThisSet < *toBeCompared )
324 {
325 ++fromThisSet;
326 }
327 else if( *fromThisSet == *toBeCompared )
328 {
329 returnBool = true;
330 }
331 else
332 {
333 ++toBeCompared;
334 }
335 }
336 return returnBool;
337 }

◆ copyAndReturnPointer()

template<class PointerClass , class ValueClass >
PointersWithValue< PointerClass, ValueClass > * LHPC::PointersWithValue< PointerClass, ValueClass >::copyAndReturnPointer ( PointersWithValue< PointerClass, ValueClass > const &  copySource)
inline

Definition at line 123 of file PointersWithValue.hpp.

125 {
126 becomeCopyOf( copySource );
127 return this;
128 }
void becomeCopyOf(PointersWithValue< PointerClass, ValueClass > const &copySource)

◆ getListSize()

template<class PointerClass , class ValueClass >
int LHPC::PointersWithValue< PointerClass, ValueClass >::getListSize
inline

Definition at line 146 of file PointersWithValue.hpp.

147 {
148 return (int)(pointerList.size());
149 }

◆ getPairedValue()

template<class PointerClass , class ValueClass >
ValueClass LHPC::PointersWithValue< PointerClass, ValueClass >::getPairedValue
inline

Definition at line 161 of file PointersWithValue.hpp.

162 {
163 return pairedValue;
164 }

◆ getPointerList() [1/2]

template<class PointerClass , class ValueClass >
std::list< PointerClass > & LHPC::PointersWithValue< PointerClass, ValueClass >::getPointerList
inline

Definition at line 132 of file PointersWithValue.hpp.

133 {
134 return pointerList;
135 }

◆ getPointerList() [2/2]

template<class PointerClass , class ValueClass >
std::list< PointerClass > const & LHPC::PointersWithValue< PointerClass, ValueClass >::getPointerList
inline

Definition at line 139 of file PointersWithValue.hpp.

140 {
141 return pointerList;
142 }

◆ matchesExactly() [1/3]

template<class PointerClass , class ValueClass >
bool LHPC::PointersWithValue< PointerClass, ValueClass >::matchesExactly ( int const  firstCode,
int const  secondCode,
bool(*)(PointerClass const, int const)  comparisonFunction 
) const
inline

Definition at line 225 of file PointersWithValue.hpp.

230 {
231 if( ( 2 == pointerList.size() )
232 &&
233 ( ( (*comparisonFunction)( pointerList.front(),
234 firstCode )
235 &&
236 (*comparisonFunction)( pointerList.back(),
237 secondCode ) )
238 ||
239 ( (*comparisonFunction)( pointerList.back(),
240 firstCode )
241 &&
242 (*comparisonFunction)( pointerList.front(),
243 secondCode ) ) ) )
244 {
245 return true;
246 }
247 else
248 {
249 return false;
250 }
251 }

◆ matchesExactly() [2/3]

template<class PointerClass , class ValueClass >
bool LHPC::PointersWithValue< PointerClass, ValueClass >::matchesExactly ( PointerClass const  firstPointer,
PointerClass const  secondPointer 
) const
inline

Definition at line 184 of file PointersWithValue.hpp.

187 {
188 if( ( 2 == pointerList.size() )
189 &&
190 ( ( ( firstPointer == pointerList.front() )
191 &&
192 ( secondPointer == pointerList.back() ) )
193 ||
194 ( ( secondPointer == pointerList.front() )
195 &&
196 ( firstPointer == pointerList.back() ) ) ) )
197 {
198 return true;
199 }
200 else
201 {
202 return false;
203 }
204 }

◆ matchesExactly() [3/3]

template<class PointerClass , class ValueClass >
bool LHPC::PointersWithValue< PointerClass, ValueClass >::matchesExactly ( std::list< PointerClass > const &  sortedList) const
inline

Definition at line 208 of file PointersWithValue.hpp.

210 {
211 if( sortedList.size() == pointerList.size() )
212 {
213 return std::equal( sortedList.begin(),
214 sortedList.end(),
215 pointerList.begin() );
216 }
217 else
218 {
219 return false;
220 }
221 }

◆ operator=()

template<class PointerClass , class ValueClass >
void LHPC::PointersWithValue< PointerClass, ValueClass >::operator= ( PointersWithValue< PointerClass, ValueClass > const &  copySource)
inline

Definition at line 40 of file PointersWithValue.hpp.

41 {
42 becomeCopyOf( copySource ); }

◆ setPairedValueAndSortPointers()

template<class PointerClass , class ValueClass >
void LHPC::PointersWithValue< PointerClass, ValueClass >::setPairedValueAndSortPointers ( ValueClass const  pairedValue)
inline

Definition at line 175 of file PointersWithValue.hpp.

177 {
178 this->pairedValue = pairedValue;
179 pointerList.sort();
180 }

Member Data Documentation

◆ pairedValue

template<class PointerClass , class ValueClass >
ValueClass LHPC::PointersWithValue< PointerClass, ValueClass >::pairedValue
protected

Definition at line 78 of file PointersWithValue.hpp.

◆ pointerList

template<class PointerClass , class ValueClass >
std::list< PointerClass > LHPC::PointersWithValue< PointerClass, ValueClass >::pointerList
protected

Definition at line 77 of file PointersWithValue.hpp.


The documentation for this class was generated from the following file: