예제 #1
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="Bag&lt;T&gt;" /> class.
 /// </summary>
 /// <param name="capacity"> The initial capacity of the bag. </param>
 /// <param name="comparer"> The comparer to use when testing equality. </param>
 public Bag(int capacity, IEqualityComparer <T> comparer)
 {
     if (comparer == null)
     {
         throw new ArgumentNullException("comparer");
     }
     _data = new VisitableHashtable <T, int>(capacity, comparer);
 }
예제 #2
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="Bag&lt;T&gt;" /> class.
        /// </summary>
        /// <param name="dictionary"> The dictionary to copy values from. </param>
        Bag(IDictionary <T, int> dictionary)
        {
            #region Asserts
            Debug.Assert(dictionary != null);
            #endregion

            _data = new VisitableHashtable <T, int>(dictionary);
            // Update the count
            using (var enumerator = _data.GetEnumerator())
                while (enumerator.MoveNext())
                {
                    Count += enumerator.Current.Value;
                }
        }
예제 #3
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="Bag&lt;T&gt;" /> class.
 /// </summary>
 /// <param name="capacity"> The initial capacity of the bag. </param>
 public Bag(int capacity)
 {
     _data = new VisitableHashtable <T, int>(capacity);
 }
예제 #4
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="Bag&lt;T&gt;" /> class.
 /// </summary>
 public Bag()
 {
     _data = new VisitableHashtable <T, int>();
 }