Skip to content

Add iterator type aliases to ParamIterator#8362

Merged
timosachsenberg merged 3 commits intodevelopfrom
copilot/make-paramiterator-real-iterator
Nov 12, 2025
Merged

Add iterator type aliases to ParamIterator#8362
timosachsenberg merged 3 commits intodevelopfrom
copilot/make-paramiterator-real-iterator

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 6, 2025

ParamIterator was missing the required type aliases (iterator_category, value_type, difference_type, pointer, reference) that enable C++ standard library algorithms to work with it via std::iterator_traits.

Changes

  • Param.h: Added five iterator type aliases to ParamIterator class
    • iterator_category = std::forward_iterator_tag (supports increment only)
    • value_type = Param::ParamEntry
    • difference_type = std::ptrdiff_t
    • pointer = const Param::ParamEntry*
    • reference = const Param::ParamEntry&
  • Includes: Added <iterator> and <cstddef> headers
  • Tests: Added unit tests verifying type traits work correctly with std::iterator_traits

Usage

ParamIterator now works with STL algorithms:

Param param;
// ... populate param ...

// Now works:
auto count = std::distance(param.begin(), param.end());
auto it = std::find_if(param.begin(), param.end(), 
    [](const auto& entry) { return entry.value.type() == ParamValue::INT_VALUE; });

Pattern follows existing OpenMS iterators like IntensityIteratorWrapper.

Original prompt

This section details on the original issue you should resolve

<issue_title>Make ParamIterator a real iterator</issue_title>
<issue_description>https://github.com/OpenMS/OpenMS/blob/develop/src/openms/include/OpenMS/DATASTRUCTURES/Param.h#L167

iterator tags etc. are missing</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 6, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

- Add iterator_category (std::forward_iterator_tag)
- Add value_type (Param::ParamEntry)
- Add difference_type (std::ptrdiff_t)
- Add pointer (const Param::ParamEntry*)
- Add reference (const Param::ParamEntry&)
- Add necessary includes (<iterator> and <cstddef>)
- Add comprehensive tests for iterator traits

Co-authored-by: timosachsenberg <5803621+timosachsenberg@users.noreply.github.com>
Copilot AI changed the title [WIP] Make ParamIterator a real iterator by adding missing tags Add iterator type aliases to ParamIterator Nov 6, 2025
Copilot AI requested a review from timosachsenberg November 6, 2025 06:29
@timosachsenberg timosachsenberg marked this pull request as ready for review November 6, 2025 08:15
Copy link
Copy Markdown
Contributor

@timosachsenberg timosachsenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good... let's wait unil mac passes

@timosachsenberg timosachsenberg merged commit 9b55e34 into develop Nov 12, 2025
26 of 27 checks passed
@timosachsenberg timosachsenberg deleted the copilot/make-paramiterator-real-iterator branch November 12, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make ParamIterator a real iterator

2 participants