feat: adding sensible index constructors refs: NOISSUE

This commit is contained in:
Simon Diesenreiter 2024-12-12 20:03:07 +01:00
parent 7e5ab9f799
commit e9aa60524c
3 changed files with 14 additions and 8 deletions

View File

@ -4,11 +4,22 @@ namespace Parsing.Data;
public class SearchResult<TIndexType>
{
public SearchResult(IDataIndex<TIndexType> dataIndex)
{
this.DataIndex = dataIndex;
}
public IDataIndex<TIndexType>? DataIndex { get; set; }
}
public class DirectionalSearchResult<TIndexType> : SearchResult<TIndexType>
{
public DirectionalSearchResult(IDataIndex<TIndexType> dataIndex, Direction direction, int length): base(dataIndex)
{
this.Direction = direction;
this.Length = length;
}
public Direction Direction { get; set; }
public int Length { get; set; }
}
@ -111,10 +122,7 @@ public abstract class DataSetManipulatorBase<TCollectedType, TDataType, TIndexTy
}
if (searchIndex == data.Count)
{
var result = new DirectionalSearchResult<TIndexType>();
result.DataIndex = currentPosition;
result.Direction = direction;
result.Length = searchIndex;
var result = new DirectionalSearchResult<TIndexType>(currentPosition, direction, searchIndex);
results.Add(result);
}
}

View File

@ -49,8 +49,7 @@ public class DefaultOneDimensionalManipulator<TDataType> : DataSetManipulatorBas
{
if (EqualityComparer<TDataType>.Default.Equals(this.dataSet[i], data))
{
var singleResult = new SearchResult<int>();
singleResult.DataIndex = new DefaultPositionalDataIndex(i);
var singleResult = new SearchResult<int>(new DefaultPositionalDataIndex(i));
results.Add(singleResult);
}
}

View File

@ -71,8 +71,7 @@ public class DefaultTwoDimensionalManipulator<TDataType> : DataSetManipulatorBas
{
if (EqualityComparer<TDataType>.Default.Equals(this.dataSet[this.dataSet.Count - y - 1][x], data))
{
var singleResult = new SearchResult<int>();
singleResult.DataIndex = new DefaultPositionalDataIndex(x, y);
var singleResult = new SearchResult<int>(new DefaultPositionalDataIndex(x, y));
results.Add(singleResult);
}
}