Skip to content

Commit a9ce311

Browse files
committed
Revert "Fixed Issue aalhour#139 A new SkipList<int> contains 0"
This reverts commit 9cab153.
1 parent 9cab153 commit a9ce311

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

DataStructures/Lists/SkipList.cs

+3-7
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,15 @@ public bool Remove(T item, out T deleted)
194194
/// </summary>
195195
public bool Contains(T item)
196196
{
197-
return Find(item, out var _);
197+
T itemOut;
198+
return Find(item, out itemOut);
198199
}
199200

200201
/// <summary>
201202
/// Look for an element and return it if found
202203
/// </summary>
203204
public bool Find(T item, out T result)
204205
{
205-
result = default;
206-
if(IsEmpty)
207-
{
208-
return false;
209-
}
210-
211206
var current = _firstNode;
212207

213208
// Walk after all the nodes that have values less than the node we are looking for
@@ -224,6 +219,7 @@ public bool Find(T item, out T result)
224219
return true;
225220
}
226221

222+
result = default(T);
227223
return false;
228224
}
229225

UnitTest/DataStructuresTests/SkipListTest.cs

-10
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ namespace UnitTest.DataStructuresTests
66
{
77
public static class SkipListTest
88
{
9-
[Fact]
10-
public static void EmptyList()
11-
{
12-
var skipList = new SkipList<int>();
13-
14-
Assert.True(skipList.Count == 0);
15-
Assert.True(skipList.IsEmpty);
16-
Assert.DoesNotContain(0, skipList);
17-
}
18-
199
[Fact]
2010
public static void AddOneElement()
2111
{

0 commit comments

Comments
 (0)