Beispiel #1
0
 /// <summary>
 /// Creates a new OrderedDictionary. The Compare method of the passed comparison object
 /// will be used to compare keys in this dictionary.
 /// </summary>
 /// <remarks>
 /// The GetHashCode and Equals methods of the provided IComparer&lt;TKey&gt; will never
 /// be called, and need not be implemented.</remarks>
 /// <param name="comparer">An instance of IComparer&lt;TKey&gt; that will be used to compare keys.</param>
 public OrderedDictionary(IComparer <TKey> comparer)
     : this(null, comparer, Comparers.ComparerKeyValueFromComparerKey <TKey, TValue>(comparer))
 {
     comparer.ShouldNotBeNull("comparer");
 }
Beispiel #2
0
 /// <summary>
 /// Creates a new OrderedDictionary. The passed delegate will be used to compare keys in this dictionary.
 /// </summary>
 /// <param name="comparison">A delegate to a method that will be used to compare keys.</param>
 public OrderedDictionary(Comparison <TKey> comparison) :
     this(
         null, Comparers.ComparerFromComparison <TKey>(comparison),
         Comparers.ComparerKeyValueFromComparisonKey <TKey, TValue>(comparison))
 {
 }
Beispiel #3
0
 /// <summary>
 /// <para>Creates a new OrderedDictionary. The passed delegate will be used to compare keys in this dictionary.</para>
 /// <para>A collection and keys and values (typically another dictionary) is used to initialized the
 /// contents of the dictionary.</para>
 /// </summary>
 /// <param name="keysAndValues">A collection of keys and values whose contents are used to initialized the dictionary.</param>
 /// <param name="comparison">A delegate to a method that will be used to compare keys.</param>
 public OrderedDictionary(IEnumerable <KeyValuePair <TKey, TValue> > keysAndValues, Comparison <TKey> comparison)
     : this(
         keysAndValues, Comparers.ComparerFromComparison <TKey>(comparison),
         Comparers.ComparerKeyValueFromComparisonKey <TKey, TValue>(comparison))
 {
 }
Beispiel #4
0
 /// <summary>
 /// Creates a new OrderedDictionary. The TKey must implemented IComparable&lt;TKey&gt;
 /// or IComparable.
 /// The CompareTo method of this interface will be used to compare keys in this dictionary.
 /// </summary>
 /// <exception cref="InvalidOperationException">TKey does not implement IComparable&lt;TKey&gt;.</exception>
 public OrderedDictionary() : this(Comparers.DefaultComparer <TKey>())
 {
 }
Beispiel #5
0
 /// <summary>
 /// <para>Creates a new OrderedDictionary. The Compare method of the passed comparison object
 /// will be used to compare keys in this dictionary.</para>
 /// <para>A collection and keys and values (typically another dictionary) is used to initialized the
 /// contents of the dictionary.</para>
 /// </summary>
 /// <remarks>
 /// The GetHashCode and Equals methods of the provided IComparer&lt;TKey&gt; will never
 /// be called, and need not be implemented.</remarks>
 /// <param name="keysAndValues">A collection of keys and values whose contents are used to initialized the dictionary.</param>
 /// <param name="comparer">An instance of IComparer&lt;TKey&gt; that will be used to compare keys.</param>
 public OrderedDictionary(IEnumerable <KeyValuePair <TKey, TValue> > keysAndValues, IComparer <TKey> comparer)
     : this(keysAndValues, comparer, Comparers.ComparerKeyValueFromComparerKey <TKey, TValue>(comparer))
 {
     comparer.ShouldNotBeNull("comparer");
 }
Beispiel #6
0
 /// <summary>
 /// <para>Creates a new OrderedDictionary. The TKey must implemented IComparable&lt;TKey&gt;
 /// or IComparable.
 /// The CompareTo method of this interface will be used to compare keys in this dictionary.</para>
 /// <para>A collection and keys and values (typically another dictionary) is used to initialized the
 /// contents of the dictionary.</para>
 /// </summary>
 /// <param name="keysAndValues">A collection of keys and values whose contents are used to initialized the dictionary.</param>
 /// <exception cref="InvalidOperationException">TKey does not implement IComparable&lt;TKey&gt;.</exception>
 public OrderedDictionary(IEnumerable <KeyValuePair <TKey, TValue> > keysAndValues)
     : this(keysAndValues, Comparers.DefaultComparer <TKey>())
 {
 }
Beispiel #7
0
 /// <summary>
 /// Create a new OrderedMultiDictionary. If duplicate values
 /// are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo"
 /// could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can
 /// be associated with the same key, although different keys can have the same value. For example, the key "foo" could
 /// have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it.
 /// </summary>
 /// <param name="allowDuplicateValues">Can the same value be associated with a key multiple times?</param>
 /// <param name="keyComparer">An IComparer&lt;TKey&gt; instance that will be used to compare keys.</param>
 /// <exception cref="InvalidOperationException">TValue does not implement either IComparable&lt;TValue&gt; or IComparable.</exception>
 public OrderedMultiDictionary(bool allowDuplicateValues, IComparer <TKey> keyComparer)
     : this(allowDuplicateValues, keyComparer, Comparers.DefaultComparer <TValue>())
 {
 }
Beispiel #8
0
 /// <summary>
 /// Create a new OrderedMultiDictionary. If duplicate values
 /// are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo"
 /// could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can
 /// be associated with the same key, although different keys can have the same value. For example, the key "foo" could
 /// have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it.
 /// </summary>
 /// <param name="allowDuplicateValues">Can the same value be associated with a key multiple times?</param>
 /// <param name="keyComparison">A delegate to a method that will be used to compare keys.</param>
 /// <param name="valueComparison">A delegate to a method that will be used to compare values.</param>
 public OrderedMultiDictionary(bool allowDuplicateValues, Comparison <TKey> keyComparison, Comparison <TValue> valueComparison)
     : this(
         allowDuplicateValues, Comparers.ComparerFromComparison(keyComparison), Comparers.ComparerFromComparison(valueComparison)
         )
 {
 }
Beispiel #9
0
 //[ExpectedException(typeof(InvalidOperationException))]
 public void UnorderableType2()
 {
     Assert.Throws <InvalidOperationException>(() => Comparers.DefaultComparer <Unorderable>());
     //IComparer<Unorderable> ordering = Comparers.DefaultComparer<Unorderable>();
 }