libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::spectree::Bucket Class Reference

#include <bucket.h>

Public Member Functions

 Bucket (std::size_t val)
 
 Bucket (const Bucket &other)
 
std::size_t getId () const
 
void push_back (std::size_t cart)
 
std::size_t size () const
 
bool operator< (const Bucket &bucket_two) const
 
const std::vector< std::size_t > & getCartList () const
 
std::size_t front () const
 get the first cart id of the list
 
std::size_t back () const
 get the last cart id of the list
 

Private Attributes

std::size_t m_itemId
 
std::vector< std::size_t > m_cartList
 

Detailed Description

Definition at line 55 of file bucket.h.

Constructor & Destructor Documentation

◆ Bucket() [1/2]

pappso::spectree::Bucket::Bucket ( std::size_t  val)

Bucket creation with appropriated initialisation for the identifiers and the mass value.

Parameters
valthe mass value (item id) associated to the bucket
Returns
b a bucket object properly instanciated
Since
0.1

Definition at line 45 of file bucket.cpp.

46{
47 m_itemId = val;
48}
std::size_t m_itemId
Definition bucket.h:118

References m_itemId.

◆ Bucket() [2/2]

pappso::spectree::Bucket::Bucket ( const Bucket other)

Definition at line 50 of file bucket.cpp.

50 : m_cartList(other.m_cartList)
51{
52 m_itemId = other.m_itemId;
53}
std::vector< std::size_t > m_cartList
Definition bucket.h:127

References m_itemId.

Member Function Documentation

◆ back()

std::size_t pappso::spectree::Bucket::back ( ) const

get the last cart id of the list

Definition at line 103 of file bucket.cpp.

104{
105 return m_cartList.back();
106}

References m_cartList.

◆ front()

std::size_t pappso::spectree::Bucket::front ( ) const

get the first cart id of the list

Definition at line 97 of file bucket.cpp.

98{
99 return m_cartList.front();
100}

References m_cartList.

◆ getCartList()

const std::vector< std::size_t > & pappso::spectree::Bucket::getCartList ( ) const

Definition at line 109 of file bucket.cpp.

110{
111 return m_cartList;
112}

References m_cartList.

◆ getId()

std::size_t pappso::spectree::Bucket::getId ( ) const

Accessor to the mass value (item id) associated to the bucket.

Returns
the mass value
Since
0.1

Definition at line 68 of file bucket.cpp.

69{
70 return m_itemId;
71}

References m_itemId.

◆ operator<()

bool pappso::spectree::Bucket::operator< ( const Bucket bucket_two) const

Implementation of the comparable interface in order to be able to compare two buckets and sort a collection of buckets lexicographically.

Parameters
bThe bucket to compare with the current one
Returns
-x if the bucket is lexicographically smaller, +x if the bucket is lexicographically bigger and 0 if they have the same content, where x is a non-zero integer.
Since
0.1

Definition at line 74 of file bucket.cpp.

76{
77
78 auto it_bucket_end = m_cartList.end();
79 auto it_bucket_b_end = bucket_b.m_cartList.end();
80
81 auto it_bucket = m_cartList.begin();
82 auto it_bucket_b = bucket_b.m_cartList.begin();
83
84 for(; it_bucket != it_bucket_end && it_bucket_b != it_bucket_b_end;
85 it_bucket++, it_bucket_b++)
86 {
87 if(*it_bucket != *it_bucket_b)
88 return (*it_bucket < *it_bucket_b);
89 }
90
91 // When the buckets have an equal content until the limit, the shortest one
92 // is returned first
93 return (m_cartList.size() < bucket_b.m_cartList.size());
94}

References m_cartList.

◆ push_back()

void pappso::spectree::Bucket::push_back ( std::size_t  cart)

Insertion of a new identifier in the bucket. Insertion happen to the end.

Parameters
cartThe cart identifier to add in the bucket
Since
0.1

Definition at line 56 of file bucket.cpp.

57{
58 m_cartList.push_back(cart);
59}

References m_cartList.

◆ size()

std::size_t pappso::spectree::Bucket::size ( ) const

Return the number of identifiers contained in the bucket.

Returns
the number of identifiers
Since
0.1

Definition at line 62 of file bucket.cpp.

63{
64 return m_cartList.size();
65}

References m_cartList.

Member Data Documentation

◆ m_cartList

std::vector<std::size_t> pappso::spectree::Bucket::m_cartList
private

Spectrum identifiers stored in an optimized array to reduce the memory occupation (fastutils). This list can only be filled, sorted or accessed in read-only.

Since
0.1

Definition at line 127 of file bucket.h.

Referenced by back(), front(), getCartList(), operator<(), push_back(), and size().

◆ m_itemId

std::size_t pappso::spectree::Bucket::m_itemId
private

The mass value associated to the bucket. This value cannot be modified.

Since
0.1

Definition at line 118 of file bucket.h.

Referenced by Bucket(), Bucket(), and getId().


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