Line data Source code
1 : // SPDX-FileCopyrightText: 2024 PairInteraction Developers 2 : // SPDX-License-Identifier: LGPL-3.0-or-later 3 : 4 : #include "pairinteraction/interfaces/SorterBuilderInterface.hpp" 5 : 6 : namespace pairinteraction { 7 : 8 1379 : IndicesOfBlock::IndicesOfBlock(size_t start, size_t end) : start(start), end(end) {} 9 : 10 2729 : size_t IndicesOfBlock::size() const { return end - start; } 11 : 12 660 : IndicesOfBlocksCreator::IndicesOfBlocksCreator(std::initializer_list<size_t> boundaries) 13 660 : : boundaries(boundaries) {} 14 : 15 735 : void IndicesOfBlocksCreator::add(size_t boundary) { boundaries.insert(boundary); } 16 : 17 660 : std::vector<IndicesOfBlock> IndicesOfBlocksCreator::create() const { 18 660 : std::vector<IndicesOfBlock> blocks; 19 660 : if (boundaries.empty()) { 20 0 : return blocks; 21 : } 22 : 23 656 : auto it = boundaries.begin(); 24 660 : size_t start = *it++; 25 : 26 2006 : while (it != boundaries.end()) { 27 1361 : blocks.emplace_back(start, *it); 28 1355 : start = *it++; 29 : } 30 : 31 654 : return blocks; 32 0 : } 33 : 34 0 : size_t IndicesOfBlocksCreator::size() const { 35 0 : return boundaries.empty() ? 0 : boundaries.size() - 1; 36 : } 37 : } // namespace pairinteraction