Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class LineBuffer : IEnumerable<char>
{
private readonly char[] _buffer = new char[80];
private readonly int _count;

public LineBuffer(ReadOnlySpan<char> buffer)
{
Expand All @@ -18,10 +19,30 @@ public LineBuffer(ReadOnlySpan<char> buffer)
{
_buffer[i] = buffer[i];
}
_count = number;
}

public IEnumerator<char> GetEnumerator() => _buffer.AsEnumerable<char>().GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => _buffer.GetEnumerator();
public int Count => _count;

public char this[int index]
{
get
{
if ((uint)index >= (uint)_count)
throw new IndexOutOfRangeException();
return _buffer[index];
}
}

public IEnumerator<char> GetEnumerator()
{
for (int i = 0; i < _count; i++)
{
yield return _buffer[i];
}
}

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

// etc
}
Expand Down
Loading