mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-15 09:08:04 +00:00
Afirma + documentation +semver: patch
This commit is contained in:
@@ -7,8 +7,8 @@ namespace QuanTAlib;
|
||||
public class CircularBuffer : IEnumerable<double>
|
||||
{
|
||||
private readonly double[] _buffer;
|
||||
private int _start;
|
||||
private int _size;
|
||||
private int _start = 0;
|
||||
private int _size = 0;
|
||||
|
||||
public int Capacity { get; }
|
||||
public int Count => _size;
|
||||
@@ -69,9 +69,7 @@ public class CircularBuffer : IEnumerable<double>
|
||||
public double Newest()
|
||||
{
|
||||
if (_size == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return _buffer[(_start + _size - 1) % Capacity];
|
||||
}
|
||||
|
||||
@@ -79,9 +77,7 @@ public class CircularBuffer : IEnumerable<double>
|
||||
public double Oldest()
|
||||
{
|
||||
if (_size == 0)
|
||||
{
|
||||
ThrowInvalidOperationException();
|
||||
}
|
||||
return _buffer[_start];
|
||||
}
|
||||
|
||||
@@ -113,9 +109,7 @@ public class CircularBuffer : IEnumerable<double>
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (_index + 1 >= _buffer._size)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_index++;
|
||||
_current = _buffer[_index];
|
||||
@@ -131,9 +125,7 @@ public class CircularBuffer : IEnumerable<double>
|
||||
_current = default;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
// not implemented
|
||||
}
|
||||
public void Dispose() { }
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
Reference in New Issue
Block a user