35 #ifndef OPENMS_CONCEPT_UNIQUEIDINDEXER_H
36 #define OPENMS_CONCEPT_UNIQUEIDINDEXER_H
42 #ifdef _MSC_VER // disable some BOOST warnings that distract from ours
43 # pragma warning( push ) // save warning state
44 # pragma warning( disable : 4396 )
47 #include <boost/unordered_map.hpp>
50 # pragma warning( pop ) // restore old warning state
63 template <
typename RandomAccessContainer>
92 if (
getBase_().at(index).getUniqueId() != unique_id)
94 throw std::out_of_range(
"unique_id_to_index_");
97 catch (std::out_of_range &)
104 catch (std::out_of_range &)
119 Size num_valid_unique_id = 0;
121 for (
Size index = 0; index <
getBase_().size(); ++index)
127 ++num_valid_unique_id;
134 if (iter->second >=
getBase_().size() ||
getBase_()[iter->second].getUniqueId() != iter->first)
145 std::stringstream ss;
146 ss <<
"Duplicate valid unique ids detected! RandomAccessContainer has size()==" <<
getBase_().size();
147 ss <<
", num_valid_unique_id==" << num_valid_unique_id;
170 Size invalid_uids(0);
173 for (
Size index = 0; index <
getBase_().size(); ++index)
179 unique_id =
getBase_()[index].getUniqueId();
186 unique_id =
getBase_()[index].getUniqueId();
214 const RandomAccessContainer &
217 return *
static_cast<const RandomAccessContainer *
>(
this);
224 RandomAccessContainer &
227 return *
static_cast<RandomAccessContainer *
>(
this);
240 #endif // OPENMS_CONCEPT_UNIQUEIDINDEXER_H
RandomAccessContainer & getBase_()
A little helper to get access to the base (!) class RandomAccessContainer.
Definition: UniqueIdIndexer.h:225
const RandomAccessContainer & getBase_() const
A little helper to get access to the base (!) class RandomAccessContainer.
Definition: UniqueIdIndexer.h:215
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Definition: UniqueIdInterface.h:62
static bool isValid(UInt64 unique_id)
Returns true if the unique_id is valid, false otherwise.
Definition: UniqueIdInterface.h:70
Size resolveUniqueIdConflicts()
Assign new UID's to doubly occurring UID's.
Definition: UniqueIdIndexer.h:168
void updateUniqueIdToIndex() const
Updates the hash map from unique id to index.
Definition: UniqueIdIndexer.h:117
Size uniqueIdToIndex(UInt64 unique_id) const
Returns the index of the feature with the given unique id, or Size(-1) if none exists in this random ...
Definition: UniqueIdIndexer.h:86
A base class for random access containers for classes derived from UniqueIdInterface that adds functi...
Definition: UniqueIdIndexer.h:64
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:71
void swap(UniqueIdIndexer &rhs)
Swap.
Definition: UniqueIdIndexer.h:202
Postcondition failed exception.
Definition: Exception.h:181
boost::unordered_map< UInt64, Size > UniqueIdMap
Definition: UniqueIdIndexer.h:68
UniqueIdMap uniqueid_to_index_
hash map from unique id to index of features
Definition: UniqueIdIndexer.h:234