Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneWandererProductions committed Jan 21, 2025
1 parent 2439615 commit 7405c57
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 21 deletions.
51 changes: 42 additions & 9 deletions CommonLibraryTests/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,26 @@ public void Sequencer()
}

/// <summary>
/// Finds the sequences should return correct result when there are sequences.
/// Finds the sequences should return correct result when there are sequences.
/// </summary>
[TestMethod]
public void FindSequencesShouldReturnCorrectResultWhenThereAreSequences()
{
// Arrange
var numbers = new List<int> { 1, 1, 2, 4, 4, 5, 6, 6, 2, 3, 3 };
var numbers = new List<int>
{
1,
1,
2,
4,
4,
5,
6,
6,
2,
3,
3
};

// Act
var result = Utility.FindSequences(numbers);
Expand All @@ -140,7 +153,7 @@ public void FindSequencesShouldReturnCorrectResultWhenThereAreSequences()


/// <summary>
/// Finds the sequences should return empty when list is empty.
/// Finds the sequences should return empty when list is empty.
/// </summary>
[TestMethod]
public void FindSequencesShouldReturnEmptyWhenListIsEmpty()
Expand All @@ -156,7 +169,7 @@ public void FindSequencesShouldReturnEmptyWhenListIsEmpty()
}

/// <summary>
/// Finds the sequences should return single sequence when all values are same.
/// Finds the sequences should return single sequence when all values are same.
/// </summary>
[TestMethod]
public void FindSequencesShouldReturnSingleSequenceWhenAllValuesAreSame()
Expand All @@ -173,7 +186,7 @@ public void FindSequencesShouldReturnSingleSequenceWhenAllValuesAreSame()
}

/// <summary>
/// Finds the sequences should handle single element list.
/// Finds the sequences should handle single element list.
/// </summary>
[TestMethod]
public void FindSequencesShouldHandleSingleElementList()
Expand All @@ -190,13 +203,20 @@ public void FindSequencesShouldHandleSingleElementList()
}

/// <summary>
/// Finds the sequences should return correct result when no sequences.
/// Finds the sequences should return correct result when no sequences.
/// </summary>
[TestMethod]
public void FindSequencesShouldReturnCorrectResultWhenNoSequences()
{
// Arrange
var numbers = new List<int> { 1, 2, 3, 4, 5 };
var numbers = new List<int>
{
1,
2,
3,
4,
5
};

// Act
var result = Utility.FindSequences(numbers);
Expand All @@ -211,13 +231,26 @@ public void FindSequencesShouldReturnCorrectResultWhenNoSequences()
}

/// <summary>
/// Finds the sequences should return correct result when list has mixed sequences.
/// Finds the sequences should return correct result when list has mixed sequences.
/// </summary>
[TestMethod]
public void FindSequencesShouldReturnCorrectResultWhenListHasMixedSequences()
{
// Arrange
var numbers = new List<int> { 1, 1, 2, 4, 4, 5, 5, 5, 6, 6, 7 };
var numbers = new List<int>
{
1,
1,
2,
4,
4,
5,
5,
5,
6,
6,
7
};

// Act
var result = Utility.FindSequences(numbers);
Expand Down
6 changes: 4 additions & 2 deletions ExtendedSystemObjects/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ public static List<KeyValuePair<int, int>> Sequencer(List<int> numbers, int step
}

/// <summary>
/// Finds the sequences.
/// Looks for consecutive numbers in a sequence.
/// Finds the sequences.
/// Looks for consecutive numbers in a sequence.
/// </summary>
/// <param name="numbers">The numbers.</param>
/// <returns>Return the start, end, and the repeated value of that streak.</returns>
Expand All @@ -320,7 +320,9 @@ public static List<KeyValuePair<int, int>> Sequencer(List<int> numbers, int step
var result = new List<(int start, int end, int value)>();

if (numbers == null || numbers.Count == 0)
{
return result;
}

var start = 0;
for (var i = 1; i <= numbers.Count; i++)
Expand Down
20 changes: 10 additions & 10 deletions Imaging/DirectBitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,18 +402,18 @@ public void SetPixelsSimd(IEnumerable<(int x, int y, Color color)> pixels)
}

/// <summary>
/// Draws the vertical lines.
/// Draws the vertical lines.
/// </summary>
/// <param name="verticalLines">The vertical lines.</param>
public void DrawVerticalLines(IEnumerable<(int x, int y, int finalY, Color color)> verticalLines)
{
_ = Parallel.ForEach(verticalLines, (line) =>
{
var (x, y, finalY, color) = line;
var colorArgb = color.ToArgb();
_ = Parallel.ForEach(verticalLines, line =>
{
var (x, y, finalY, color) = line;
var colorArgb = color.ToArgb();

// Starting position in the Bits array
var position = x + y * Width;
var position = x + (y * Width);

// Calculate the number of rows in the vertical line
var rowCount = finalY - y + 1;
Expand All @@ -423,10 +423,10 @@ public void DrawVerticalLines(IEnumerable<(int x, int y, int finalY, Color color

// Set the color for each pixel in the vertical line
for (var i = 0; i < rowCount; i++)
{
bitsSpan[position + i * Width] = colorArgb;
}
});
{
bitsSpan[position + (i * Width)] = colorArgb;
}
});
}

/// <summary>
Expand Down

0 comments on commit 7405c57

Please sign in to comment.