OpenMS
Loading...
Searching...
No Matches
NuXLFragmentAdductDefinition.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
16#include <functional>
17#include <vector>
18#include <map>
19#include <set>
20
21namespace OpenMS
22{
23struct OPENMS_DLLAPI NuXLFragmentAdductDefinition
24{
26 String name; // name used in annotation
27 double mass = 0;
28
30
32
34
35 NuXLFragmentAdductDefinition(const EmpiricalFormula& f, const String& n, double m) : formula(f), name(n), mass(m) {}
36
38
40
41 bool operator<(const NuXLFragmentAdductDefinition& other) const;
42
43 bool operator==(const NuXLFragmentAdductDefinition& other) const;
44
45};
46
47} // namespace OpenMS
48
49// Hash function specialization for NuXLFragmentAdductDefinition
50// Placed in std namespace to allow use with std::unordered_map/set
51namespace std
52{
61 template<>
62 struct hash<OpenMS::NuXLFragmentAdductDefinition>
63 {
64 std::size_t operator()(const OpenMS::NuXLFragmentAdductDefinition& fad) const noexcept
65 {
66 std::size_t seed = 0;
67 // Hash formula using EmpiricalFormula's std::hash specialization
68 OpenMS::hash_combine(seed, std::hash<OpenMS::EmpiricalFormula>{}(fad.formula));
69 // Hash name using fnv1a_hash_string (String inherits from std::string)
71 return seed;
72 }
73 };
74} // namespace std
75
Representation of an empirical formula.
Definition EmpiricalFormula.h:63
A more convenient string class.
Definition String.h:34
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
void hash_combine(std::size_t &seed, std::size_t value) noexcept
Combine a hash value with additional data using golden ratio mixing.
Definition HashUtils.h:87
std::size_t fnv1a_hash_string(const std::string &s) noexcept
FNV-1a hash for a string.
Definition HashUtils.h:70
STL namespace.
Definition NuXLFragmentAdductDefinition.h:24
bool operator<(const NuXLFragmentAdductDefinition &other) const
NuXLFragmentAdductDefinition & operator=(NuXLFragmentAdductDefinition &&)=default
bool operator==(const NuXLFragmentAdductDefinition &other) const
NuXLFragmentAdductDefinition(const EmpiricalFormula &f, const String &n, double m)
Definition NuXLFragmentAdductDefinition.h:35
String name
Definition NuXLFragmentAdductDefinition.h:26
NuXLFragmentAdductDefinition(const NuXLFragmentAdductDefinition &)=default
NuXLFragmentAdductDefinition & operator=(const NuXLFragmentAdductDefinition &)=default
EmpiricalFormula formula
Definition NuXLFragmentAdductDefinition.h:25
NuXLFragmentAdductDefinition(NuXLFragmentAdductDefinition &&)=default
std::size_t operator()(const OpenMS::NuXLFragmentAdductDefinition &fad) const noexcept
Definition NuXLFragmentAdductDefinition.h:64