-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae55589
commit d5d2df7
Showing
3 changed files
with
47 additions
and
45 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace SoundMaker.ScoreData.SMSC; | ||
internal class TokenQueue | ||
{ | ||
private readonly Queue<Token> _tokens; | ||
|
||
public TokenQueue(IEnumerable<Token> tokens) | ||
{ | ||
_tokens = new(tokens); | ||
} | ||
|
||
public Token? PrevToken { get; private set; } | ||
|
||
public int Count => _tokens.Count; | ||
|
||
public bool TryDequeue([MaybeNullWhen(false)] out Token token) | ||
{ | ||
if (_tokens.TryDequeue(out token)) | ||
{ | ||
PrevToken = token; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public Token Dequeue() | ||
{ | ||
return _tokens.Dequeue(); | ||
} | ||
|
||
public bool TryPeek([MaybeNullWhen(false)] out Token token) | ||
{ | ||
return _tokens.TryPeek(out token); | ||
} | ||
} |
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