Skip to content

Commit 2190a40

Browse files
committed
Clean up updated code based on codacy feedback
1 parent 3e4b22d commit 2190a40

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

Algorithms/Search/AStar/VecN.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public struct VecN(params double[] vals) : IEquatable<VecN>
1414
/// <summary>
1515
/// Gets the dimension count of this vector.
1616
/// </summary>
17-
public int N => data.Length;
17+
public readonly int N => data.Length;
1818

1919
/// <summary>
2020
/// Returns the Length squared.
@@ -108,4 +108,29 @@ public bool Equals(VecN other)
108108

109109
return true;
110110
}
111+
112+
/// <summary>
113+
/// Determines whether the specified object is equal to the current instance.
114+
/// </summary>
115+
/// <param name="obj">The object to compare with the current instance. Can be <see langword="null"/>.</param>
116+
/// <returns><see langword="true"/> if the specified object is a <c>VecN</c> and is equal to the current instance; otherwise <see langword="false"/>.</returns>
117+
public override bool Equals(object? obj)
118+
{
119+
return obj is VecN other && Equals(other);
120+
}
121+
122+
/// <summary>
123+
/// Computes a hash code for the current object based on the values in the <c>data</c> collection.
124+
/// </summary>
125+
/// <returns>An integer representing the hash code for the current object.</returns>
126+
public override int GetHashCode()
127+
{
128+
var hash = default(HashCode);
129+
foreach (var d in data)
130+
{
131+
hash.Add(d);
132+
}
133+
134+
return hash.ToHashCode();
135+
}
111136
}

DataStructures/LinkedList/SinglyLinkedList/SinglyLinkedListNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ public class SinglyLinkedListNode<T>(T data)
44
{
55
public T Data { get; } = data;
66

7-
public SinglyLinkedListNode<T>? Next { get; set; } = null;
7+
public SinglyLinkedListNode<T>? Next { get; set; }
88
}

DataStructures/UnrolledList/UnrolledLinkedListNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class UnrolledLinkedListNode(int nodeSize)
99

1010
public UnrolledLinkedListNode Next { get; set; } = null!;
1111

12-
public int Count { get; set; } = 0;
12+
public int Count { get; set; }
1313

1414
/// <summary>
1515
/// Set new item in array buffer.

0 commit comments

Comments
 (0)