C++ (Qt)struct Uniquer { Uniquer( int start, int increment) : mStart(start), mIncrement(increment) { } void Add( int value ) { mSet.insert(value); } int Get( void ) { auto it = mSet.lower_bound(mStart); while ((it != mSet.end()) && (mStart == *it)) { mStart += mIncrement; ++it; } int result = mStart; mSet.insert(mStart); mStart += mIncrement; return result; } // data std::set mSet; int mStart, mIncrement;};