mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-07 21:47:43 +00:00
Refactor: Update variable declarations for consistency and clarity across multiple files
This commit is contained in:
@@ -372,7 +372,7 @@ public class RingBufferTests
|
||||
buffer.Add(20.0);
|
||||
buffer.Add(30.0);
|
||||
|
||||
var values = new List<double>();
|
||||
List<double> values = [];
|
||||
foreach (var v in buffer)
|
||||
{
|
||||
values.Add(v);
|
||||
@@ -395,7 +395,7 @@ public class RingBufferTests
|
||||
buffer.Add(40.0);
|
||||
buffer.Add(50.0);
|
||||
|
||||
var values = new List<double>();
|
||||
List<double> values = [];
|
||||
foreach (var v in buffer)
|
||||
{
|
||||
values.Add(v);
|
||||
@@ -637,7 +637,7 @@ public class RingBufferTests
|
||||
buffer.Add(20.0);
|
||||
|
||||
IEnumerable<double> enumerable = buffer;
|
||||
var values = new List<double>();
|
||||
List<double> values = [];
|
||||
foreach (var v in enumerable)
|
||||
{
|
||||
values.Add(v);
|
||||
@@ -656,7 +656,7 @@ public class RingBufferTests
|
||||
buffer.Add(20.0);
|
||||
|
||||
IEnumerable enumerable = buffer;
|
||||
var values = new List<double>();
|
||||
List<double> values = [];
|
||||
foreach (var v in enumerable)
|
||||
{
|
||||
values.Add((double)v);
|
||||
|
||||
@@ -526,10 +526,10 @@ public sealed class RingBuffer : IEnumerable<double>
|
||||
_index == other._index &&
|
||||
_current.Equals(other._current);
|
||||
|
||||
public override readonly bool Equals(object? obj) =>
|
||||
public readonly override bool Equals(object? obj) =>
|
||||
obj is Enumerator other && Equals(other);
|
||||
|
||||
public override readonly int GetHashCode() =>
|
||||
public readonly override int GetHashCode() =>
|
||||
HashCode.Combine(RuntimeHelpers.GetHashCode(_buffer), _start, _count, _index, _current);
|
||||
|
||||
public static bool operator ==(Enumerator left, Enumerator right) => left.Equals(right);
|
||||
|
||||
@@ -106,14 +106,12 @@ public delegate void TBarPublishedHandler(object? sender, in TBarEventArgs args)
|
||||
|
||||
public class TBarSeries : IReadOnlyList<TBar>
|
||||
{
|
||||
#pragma warning disable MA0016 // Prefer using collection abstraction instead of implementation
|
||||
protected readonly List<long> _t;
|
||||
protected readonly List<double> _o;
|
||||
protected readonly List<double> _h;
|
||||
protected readonly List<double> _l;
|
||||
protected readonly List<double> _c;
|
||||
protected readonly List<double> _v;
|
||||
#pragma warning restore MA0016
|
||||
private readonly List<long> _t;
|
||||
private readonly List<double> _o;
|
||||
private readonly List<double> _h;
|
||||
private readonly List<double> _l;
|
||||
private readonly List<double> _c;
|
||||
private readonly List<double> _v;
|
||||
|
||||
public string Name { get; set; } = "Bar";
|
||||
public event TBarPublishedHandler? Pub;
|
||||
|
||||
@@ -99,8 +99,8 @@ public class TSeries : IReadOnlyList<TValue>, ITValuePublisher
|
||||
}
|
||||
else
|
||||
{
|
||||
_t = new List<long>(time);
|
||||
_v = new List<double>(values);
|
||||
_t = [..time];
|
||||
_v = [..values];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public readonly record struct TValue(long Time, double Value)
|
||||
double.PositiveInfinity => ((char)0x221E).ToString(),
|
||||
double.NegativeInfinity => "-" + (char)0x221E,
|
||||
_ when double.IsNaN(Value) => "NaN",
|
||||
_ => Value.ToString("F2")
|
||||
_ => Value.ToString("F2"),
|
||||
};
|
||||
return $"[{AsDateTime:yyyy-MM-dd HH:mm:ss}, {valueStr}]";
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public static class IndicatorExtensions
|
||||
int count = leftIndex - rightIndex;
|
||||
if (count <= 0) return Array.Empty<Point>();
|
||||
|
||||
Point[] allPoints = new Point[count];
|
||||
var allPoints = new Point[count];
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
@@ -191,7 +191,7 @@ public static class IndicatorExtensions
|
||||
if (showColdValues)
|
||||
{
|
||||
int coldStart = Math.Max(0, hotCount);
|
||||
int coldSegments = (count - 1) - coldStart;
|
||||
int coldSegments = count - coldStart - 1;
|
||||
|
||||
if (coldSegments > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user