Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An iterator for AList #205

Merged
merged 1 commit into from
Aug 20, 2024
Merged

Conversation

valdisz
Copy link
Contributor

@valdisz valdisz commented Aug 19, 2024

The forlist macro comes from when there were no iterators. AList is a custom container that needs to be replaced with std containers, but the amount of work is immense. Therefore I have added iterator interface (begin and end) methods so that modern for (var item : iterator) syntax can be used in the code. It will allow the removal of the forlist macro from the codebase over time.

New API

AList::begin - iterator for the beginning of the list
AList::end - iterator for the end of the list
AList::iter<T> - allows for strongly typed iteration over the AList

Improvements

  1. Will allow the use of modern C++ for loop syntax.
  2. All iterator-based APIs from std namespace will work on AList instances.

@valdisz valdisz requested a review from jt-traub August 19, 2024 21:15
Copy link
Contributor

@jt-traub jt-traub left a comment

Choose a reason for hiding this comment

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

This is good. It at least makes the code cleaner in the interim until we can actually get around to removing AList.

@valdisz valdisz merged commit ee04e99 into Atlantis-PBEM:master Aug 20, 2024
5 checks passed
@valdisz valdisz deleted the valdis/alist-iterator branch August 21, 2024 16:44
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.

2 participants