Skip to content

Commit

Permalink
Add Equals method
Browse files Browse the repository at this point in the history
  • Loading branch information
basp1 committed Jul 10, 2019
1 parent c954c8a commit 0105fad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/FlatMap.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace sharpcode
{
Expand Down Expand Up @@ -111,6 +111,16 @@ public Value this[Key key]
}
}

public override bool Equals(object obj)
{
return Equals(obj as FlatMap<Key, Value>);
}

public bool Equals(FlatMap<Key, Value> that)
{
return keys.SequenceEqual(that.keys) && values.SequenceEqual(that.values);
}

bool Find(Key key, ref Value value)
{
int index = LowerBound(key);
Expand Down
5 changes: 5 additions & 0 deletions src/SegmentTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public int Capacity
}
}

public override bool Equals(object obj)
{
return Equals(obj as SegmentTree<T>);
}

public bool Equals(SegmentTree<T> that)
{
if (capacity != that.Capacity)
Expand Down

0 comments on commit 0105fad

Please sign in to comment.