Created
September 15, 2019 12:18
-
-
Save nolawnchairs/d89768223176ace6b748aa3baf9d49cc to your computer and use it in GitHub Desktop.
Unfinished Modular iterator
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
export class ModularItem<E> { | |
private readonly _value: E | |
private _position = 0 | |
constructor(value: E, position: number = 0) { | |
this._value = value | |
this._position = position | |
} | |
advance() { | |
this._position++ | |
} | |
retreat() { | |
this._position-- | |
} | |
reset() { | |
this._position = 0 | |
} | |
get value(): E { | |
return this._value | |
} | |
get position(): number { | |
return this._position | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment