Last active
August 29, 2015 14:04
-
-
Save sherief/8b129d78ef662445a936 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class T> | |
class range | |
{ | |
public: | |
class range_iterator | |
{ | |
public: | |
range_iterator(const T Position_) : Position(Position_) | |
{ | |
} | |
range_iterator(const T Position_, const T Step_) : Position(Position_), Step(Step_) | |
{ | |
} | |
bool operator!=(const range_iterator& Other) const | |
{ | |
return (Position != Other.Position); | |
} | |
range_iterator& operator++() | |
{ | |
Position += Step; | |
return *this; | |
} | |
T operator*() const | |
{ | |
return Position; | |
} | |
private: | |
T Position; | |
T Step; | |
}; | |
range(const T Length) | |
{ | |
Start = T(0); | |
Stop = Length; | |
Step = T(1); | |
} | |
range(const T Start, const T Stop) | |
{ | |
this->Start = Start; | |
this->Stop = Stop; | |
Step = T(1); | |
} | |
range(const T Start, const T Stop, const T Step) | |
{ | |
this->Start = Start; | |
this->Stop = Stop; | |
this->Step = Step; | |
} | |
range_iterator begin() | |
{ | |
return range_iterator(Start, Step); | |
} | |
range_iterator end() | |
{ | |
return range_iterator(Stop, Step); | |
} | |
private: | |
T Start; | |
T Stop; | |
T Step; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment