10 changed files with 68 additions and 106 deletions
@ -1,46 +0,0 @@
@@ -1,46 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace Debugger.AddIn.Visualizers.Utils |
||||
{ |
||||
/// <summary>
|
||||
/// Same like Dictionary, but can store multiple values for one key.
|
||||
/// </summary>
|
||||
public class Lookup<TKey, TValue> |
||||
{ |
||||
/// <summary>Wrapped dictionary</summary>
|
||||
private Dictionary<TKey, LookupValueCollection<TValue>> dictionary; |
||||
|
||||
public Lookup() |
||||
{ |
||||
dictionary = new Dictionary<TKey, LookupValueCollection<TValue>>(); |
||||
} |
||||
|
||||
public LookupValueCollection<TValue> this[TKey key] |
||||
{ |
||||
get |
||||
{ |
||||
LookupValueCollection<TValue> values = null; |
||||
if (dictionary.TryGetValue(key, out values)) |
||||
{ |
||||
return values; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public void Add(TKey key, TValue value) |
||||
{ |
||||
LookupValueCollection<TValue> values = null; |
||||
if (!dictionary.TryGetValue(key, out values)) |
||||
{ |
||||
values = new LookupValueCollection<TValue>(); |
||||
dictionary.Add(key, values); |
||||
} |
||||
values.Add(value); |
||||
} |
||||
} |
||||
} |
||||
@ -1,15 +0,0 @@
@@ -1,15 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace Debugger.AddIn.Visualizers.Utils |
||||
{ |
||||
/// <summary>
|
||||
/// A collection of values for one key in the Lookup class.
|
||||
/// </summary>
|
||||
public class LookupValueCollection<TValue> : List<TValue> |
||||
{ |
||||
} |
||||
} |
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace Debugger.AddIn.Visualizers.Utils |
||||
{ |
||||
/// <summary> Dictionary that can store multiple values for each key.</summary>
|
||||
public class Multimap<TKey, TValue> |
||||
{ |
||||
/// <summary>Wrapped dictionary</summary>
|
||||
private Dictionary<TKey, IList<TValue>> dictionary; |
||||
|
||||
public Multimap() |
||||
{ |
||||
dictionary = new Dictionary<TKey, IList<TValue>>(); |
||||
} |
||||
|
||||
public IList<TValue> this[TKey key] |
||||
{ |
||||
get { |
||||
IList<TValue> values = null; |
||||
if (dictionary.TryGetValue(key, out values)) { |
||||
return values; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public void Add(TKey key, TValue value) |
||||
{ |
||||
IList<TValue> values = null; |
||||
if (!dictionary.TryGetValue(key, out values)) { |
||||
values = new List<TValue>(); |
||||
dictionary.Add(key, values); |
||||
} |
||||
values.Add(value); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue