Skip to content

Commit

Permalink
Revert "Fixed Issue aalhour#139 A new SkipList<int> contains 0"
Browse files Browse the repository at this point in the history
This reverts commit 9cab153.
  • Loading branch information
Gutsonok committed Aug 5, 2020
1 parent 9cab153 commit a9ce311
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
10 changes: 3 additions & 7 deletions DataStructures/Lists/SkipList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,20 +194,15 @@ public bool Remove(T item, out T deleted)
/// </summary>
public bool Contains(T item)
{
return Find(item, out var _);
T itemOut;
return Find(item, out itemOut);
}

/// <summary>
/// Look for an element and return it if found
/// </summary>
public bool Find(T item, out T result)
{
result = default;
if(IsEmpty)
{
return false;
}

var current = _firstNode;

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

result = default(T);
return false;
}

Expand Down
10 changes: 0 additions & 10 deletions UnitTest/DataStructuresTests/SkipListTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ namespace UnitTest.DataStructuresTests
{
public static class SkipListTest
{
[Fact]
public static void EmptyList()
{
var skipList = new SkipList<int>();

Assert.True(skipList.Count == 0);
Assert.True(skipList.IsEmpty);
Assert.DoesNotContain(0, skipList);
}

[Fact]
public static void AddOneElement()
{
Expand Down

0 comments on commit a9ce311

Please sign in to comment.