Skip to content

Commit

Permalink
re-introduce some special dictionary methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sebas77 committed Jun 4, 2022
1 parent a8e52bc commit d753000
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions DataStructures/Dictionaries/FasterDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ public bool Remove(TKey key)
return _dictionary.Remove(key);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Remove(TKey key, out TValue val)
{
return _dictionary.Remove(key, out _, out val);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Trim()
{
Expand Down
14 changes: 14 additions & 0 deletions DataStructures/Dictionaries/ThreadSafeDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,20 @@ public bool TryRemove(TKey key)
_lockQ.ExitWriteLock();
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool TryRemove(TKey key, out TValue val)
{
_lockQ.EnterWriteLock();
try
{
return _dict.Remove(key, out val);
}
finally
{
_lockQ.ExitWriteLock();
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Trim()
Expand Down

0 comments on commit d753000

Please sign in to comment.