LCOV - code coverage report
Current view: top level - src/engraving/dom - segmentlist.h Coverage Total Hit
Test: filtered_coverage.info Lines: 94.1 % 17 16
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #pragma once
      24              : 
      25              : #include "segment.h"
      26              : 
      27              : namespace mu::engraving {
      28              : class Segment;
      29              : 
      30              : //---------------------------------------------------------
      31              : //   SegmentList
      32              : //---------------------------------------------------------
      33              : 
      34              : class SegmentList
      35              : {
      36              : public:
      37        17166 :     SegmentList() { clear(); }
      38        17166 :     void clear() { m_first = m_last = 0; m_size = 0; }
      39              : #ifndef NDEBUG
      40              :     void check();
      41              : #else
      42              :     void check() {}
      43              : #endif
      44              :     SegmentList clone() const;
      45            0 :     int size() const { return m_size; }
      46              : 
      47              :     Segment* at(int index) const;
      48              : 
      49      2597155 :     Segment* first() const { return m_first; }
      50              :     Segment* firstActive() const;
      51              :     Segment* first(SegmentType) const;
      52              :     Segment* first(ElementFlag) const;
      53              : 
      54      1603822 :     Segment* last() const { return m_last; }
      55              :     Segment* last(ElementFlag) const;
      56              :     Segment* last(SegmentType) const;
      57              :     Segment* firstCRSegment() const;
      58              :     void remove(Segment*);
      59              :     void push_back(Segment*);
      60              :     void push_front(Segment*);
      61              :     void insert(Segment* e, Segment* el);    // insert e before el
      62              : 
      63              :     class iterator
      64              :     {
      65              :         Segment* p;
      66              :     public:
      67      6501230 :         iterator(Segment* s) { p = s; }
      68      4050048 :         iterator operator++() { iterator i(p); p = p->next(); return i; }
      69      5275639 :         bool operator !=(const iterator& i) const { return p != i.p; }
      70      4083240 :         Segment& operator*() { return *p; }
      71              :     };
      72              :     class const_iterator
      73              :     {
      74              :         const Segment* p;
      75              :     public:
      76      1271515 :         const_iterator(const Segment* s) { p = s; }
      77       792381 :         const_iterator operator++() { const_iterator i(p); p = p->next(); return i; }
      78      1031948 :         bool operator !=(const const_iterator& i) const { return p != i.p; }
      79       792676 :         const Segment& operator*() const { return *p; }
      80              :     };
      81              : 
      82      1225591 :     iterator begin() { return m_first; }
      83      1225591 :     iterator end() { return 0; }
      84       239567 :     const_iterator begin() const { return m_first; }
      85       239567 :     const_iterator end() const { return 0; }
      86              : 
      87              : private:
      88              : 
      89              :     Segment* m_first = nullptr;          // First item of segment list
      90              :     Segment* m_last = nullptr;           // Last item of segment list
      91              :     int m_size = 0;                      // Number of items in segment list
      92              : };
      93              : 
      94              : // Segment* begin(SegmentList& l) { return l.first(); }
      95              : // Segment* end(SegmentList&) { return 0; }
      96              : } // namespace mu::engraving
        

Generated by: LCOV version 2.0-1