Kylin/DataStructure/RandomIterator.h
2023-12-27 10:29:16 +08:00

26 lines
515 B
C++

#ifndef RANDOMITERATOR_H
#define RANDOMITERATOR_H
#include "Object.h"
namespace Kylin {
template <typename T>
class RandomIterator : public Object {
public:
RandomIterator(T *pos) : m_pos(pos) {}
T &operator*() { return *m_pos; }
RandomIterator &operator++() {
m_pos++;
return *this;
}
bool operator!=(const RandomIterator &other) { return m_pos != other.m_pos; }
private:
T *m_pos = nullptr;
};
} // namespace Kylin
#endif // RANDOMITERATOR_H