Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

housekeeping: Keep users from breaking with a runtime constructor change #345

Merged
merged 1 commit into from Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -663,7 +663,10 @@ namespace Splat
}
public sealed class MemoizingMRUCache<TParam, TVal>
{
public MemoizingMRUCache(System.Func<TParam, object, TVal> calculationFunc, int maxSize, System.Action<TVal> onRelease = null, System.Collections.Generic.IEqualityComparer<TParam> paramComparer = null) { }
public MemoizingMRUCache(System.Func<TParam, object, TVal> calculationFunc, int maxSize) { }
public MemoizingMRUCache(System.Func<TParam, object, TVal> calculationFunc, int maxSize, System.Action<TVal> onRelease) { }
public MemoizingMRUCache(System.Func<TParam, object, TVal> calculationFunc, int maxSize, System.Collections.Generic.IEqualityComparer<TParam> paramComparer) { }
public MemoizingMRUCache(System.Func<TParam, object, TVal> calculationFunc, int maxSize, System.Action<TVal> onRelease, System.Collections.Generic.IEqualityComparer<TParam> paramComparer) { }
public System.Collections.Generic.IEnumerable<TVal> CachedValues() { }
public TVal Get(TParam key) { }
public TVal Get(TParam key, object context = null) { }
Expand Down
Expand Up @@ -652,7 +652,10 @@ namespace Splat
}
public sealed class MemoizingMRUCache<TParam, TVal>
{
public MemoizingMRUCache(System.Func<TParam, object, TVal> calculationFunc, int maxSize, System.Action<TVal> onRelease = null, System.Collections.Generic.IEqualityComparer<TParam> paramComparer = null) { }
public MemoizingMRUCache(System.Func<TParam, object, TVal> calculationFunc, int maxSize) { }
public MemoizingMRUCache(System.Func<TParam, object, TVal> calculationFunc, int maxSize, System.Action<TVal> onRelease) { }
public MemoizingMRUCache(System.Func<TParam, object, TVal> calculationFunc, int maxSize, System.Collections.Generic.IEqualityComparer<TParam> paramComparer) { }
public MemoizingMRUCache(System.Func<TParam, object, TVal> calculationFunc, int maxSize, System.Action<TVal> onRelease, System.Collections.Generic.IEqualityComparer<TParam> paramComparer) { }
public System.Collections.Generic.IEnumerable<TVal> CachedValues() { }
public TVal Get(TParam key) { }
public TVal Get(TParam key, object context = null) { }
Expand Down
45 changes: 44 additions & 1 deletion src/Splat/MemoizingMRUCache.cs
Expand Up @@ -35,6 +35,49 @@ public sealed class MemoizingMRUCache<TParam, TVal>
private LinkedList<TParam> _cacheMRUList;
private Dictionary<TParam, (LinkedListNode<TParam> param, TVal value)> _cacheEntries;

/// <summary>
/// Initializes a new instance of the <see cref="MemoizingMRUCache{TParam, TVal}"/> class.
/// </summary>
/// <param name="calculationFunc">The function whose results you want to cache,
/// which is provided the key value, and an Tag object that is
/// user-defined.</param>
/// <param name="maxSize">The size of the cache to maintain, after which old
/// items will start to be thrown out.</param>
public MemoizingMRUCache(Func<TParam, object, TVal> calculationFunc, int maxSize)
: this(calculationFunc, maxSize, null, EqualityComparer<TParam>.Default)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="MemoizingMRUCache{TParam, TVal}"/> class.
/// </summary>
/// <param name="calculationFunc">The function whose results you want to cache,
/// which is provided the key value, and an Tag object that is
/// user-defined.</param>
/// <param name="maxSize">The size of the cache to maintain, after which old
/// items will start to be thrown out.</param>
/// <param name="onRelease">A function to call when a result gets
/// evicted from the cache (i.e. because Invalidate was called or the
/// cache is full).</param>
public MemoizingMRUCache(Func<TParam, object, TVal> calculationFunc, int maxSize, Action<TVal> onRelease)
: this(calculationFunc, maxSize, onRelease, EqualityComparer<TParam>.Default)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="MemoizingMRUCache{TParam, TVal}"/> class.
/// </summary>
/// <param name="calculationFunc">The function whose results you want to cache,
/// which is provided the key value, and an Tag object that is
/// user-defined.</param>
/// <param name="maxSize">The size of the cache to maintain, after which old
/// items will start to be thrown out.</param>
/// <param name="paramComparer">A comparer for the parameter.</param>
public MemoizingMRUCache(Func<TParam, object, TVal> calculationFunc, int maxSize, IEqualityComparer<TParam> paramComparer)
: this(calculationFunc, maxSize, null, paramComparer)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="MemoizingMRUCache{TParam, TVal}"/> class.
/// </summary>
Expand All @@ -47,7 +90,7 @@ public sealed class MemoizingMRUCache<TParam, TVal>
/// evicted from the cache (i.e. because Invalidate was called or the
/// cache is full).</param>
/// <param name="paramComparer">A comparer for the parameter.</param>
public MemoizingMRUCache(Func<TParam, object, TVal> calculationFunc, int maxSize, Action<TVal> onRelease = null, IEqualityComparer<TParam> paramComparer = null)
public MemoizingMRUCache(Func<TParam, object, TVal> calculationFunc, int maxSize, Action<TVal> onRelease, IEqualityComparer<TParam> paramComparer)
{
Contract.Requires(calculationFunc != null);
Contract.Requires(maxSize > 0);
Expand Down