namespace AIStudio.Tools;
///
/// Represents a target window for the number of items to match a threshold.
///
/// The minimum number of items to match the threshold. Should be at least one and less than targetWindowMin.
/// The minimum number of items in the target window. Should be at least 2 and more than numMinItems.
/// The maximum number of items in the target window.
public readonly record struct TargetWindow(int NumMinItems, int TargetWindowMin, int TargetWindowMax, float MinThreshold)
{
///
/// Determines if the target window is valid.
///
/// True when the target window is valid; otherwise, false.
public bool IsValid()
{
if(this.NumMinItems < 1)
return false;
if(this.TargetWindowMin < this.NumMinItems)
return false;
if(this.TargetWindowMax < this.TargetWindowMin)
return false;
if(this.MinThreshold is < 0f or > 1f)
return false;
return true;
}
///
/// Determines if the number of items is inside the target window.
///
/// The number of items to check.
/// True when the number of items is inside the target window; otherwise, false.
public bool InsideWindow(int numItems) => numItems >= this.TargetWindowMin && numItems <= this.TargetWindowMax;
}