Work in Progress

This commit is contained in:
Michael Schimmel
2025-07-15 20:29:19 +02:00
parent 8ebcd81561
commit bc75f08477
13 changed files with 597 additions and 320 deletions
+6 -3
View File
@@ -24,7 +24,7 @@ type
class operator Initialize(out Dest: TSeries<T>);
// Add a singe item
function Add(const Data: T; Lookback: Int64): TSeries<T>; overload;
function Add(const Data: T; Lookback: Int64 = -1): TSeries<T>; overload;
// Add a ranmge of items
function Add(const Data: array of T; First, Count, Lookback: Int64): TSeries<T>; overload;
// Helper to create a data array from a raw TArray.
@@ -36,6 +36,9 @@ type
implementation
uses
System.Math;
{ TSeries<T> }
constructor TSeries<T>.Create(const AChunks: TArray<TChunk>; ACount, ATotalCount: Int64);
@@ -62,14 +65,14 @@ var
begin
if Count < 0 then
Count := Length(Data) - First;
if (Lookback <= 0) or (Count = 0) then
if Count = 0 then
exit(Self);
Assert(Count <= (Length(Data) - First), 'Count cannot be larger than the source array');
sumCount := FCount + Count;
newCount := sumCount;
if (Lookback > 0) and (newCount > Lookback) then
if (Lookback >= 0) and (newCount > Lookback) then
newCount := Lookback;
itemsToSkip := sumCount - newCount;