Skip to content

Commit 00733e1

Browse files
committed
set default comparer when not provided for value types
1 parent 1fc8dfc commit 00733e1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Advanced.Algorithms/DataStructures/Tree/RedBlackTree.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public RedBlackTree(bool enableNodeLookUp = false, IEqualityComparer<T> equality
3030
throw new ArgumentException("equalityComparer parameter is required when node lookup us enabled and T is not a value type.");
3131
}
3232

33-
NodeLookUp = new Dictionary<T, BSTNodeBase<T>>(equalityComparer);
33+
NodeLookUp = new Dictionary<T, BSTNodeBase<T>>(equalityComparer ?? EqualityComparer<T>.Default);
3434
}
3535
}
3636

@@ -58,7 +58,7 @@ public RedBlackTree(IEnumerable<T> sortedCollection, bool enableNodeLookUp = fal
5858
throw new ArgumentException("equalityComparer parameter is required when node lookup us enabled and T is not a value type.");
5959
}
6060

61-
NodeLookUp = nodes.ToDictionary(x => x.Value, x => x as BSTNodeBase<T>);
61+
NodeLookUp = nodes.ToDictionary(x => x.Value, x => x as BSTNodeBase<T>, equalityComparer ?? EqualityComparer<T>.Default);
6262
}
6363
}
6464

0 commit comments

Comments
 (0)