Skip to content
/ ItorCirc Public

warpper to make erasing iterator in C++ circulation easier

License

Notifications You must be signed in to change notification settings

2mhk/ItorCirc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ItorCirc

wrapper to make erasing iterator in C++ circulation easier

Notes

No more crash will be caused by ItorCirc.

But still be careful with the iterator by what it will be in the next cycle.

Examples

Here is a simple example to show you how to use.

Beside the example below, you can find advance using in sample.cpp.

#include "ItorCirc.h"
#include <vector>

void main()
{
    std::vector<int> vecData = { 1,2,3,4,5,6,7,8,9,10 };
    for (ItorCirc<decltype(vecData)> itor_vecData(vecData); !itor_vecData.isEnd(); itor_vecData.fetch_add())
    {
        int data = *itor_vecData.get_Iterator();
        if (data == 6) {
            itor_vecData.erase(itor_vecData.get_Iterator()); 			//or itor_vecData.erase_current();
            for (auto item : vecData) { std::cout << item << " "; }		//  1 2 3 4 5 7 8 9 10
        }
    }
}

About

warpper to make erasing iterator in C++ circulation easier

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages