本文整理匯總了C#中Bag.NumberOfCopies方法的典型用法代碼示例。如果您正苦於以下問題:C# Bag.NumberOfCopies方法的具體用法?C# Bag.NumberOfCopies怎麽用?C# Bag.NumberOfCopies使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Bag
的用法示例。
在下文中一共展示了Bag.NumberOfCopies方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestBag
/// <summary>
/// Bag<T>
/// A bag (multi-set) based on hash-table (WITH DUPLICATES)
/// Unordered collection
/// Add / Find / Remove work in time O(1)
/// T should provide Equals() and GetHashCode()
/// </summary>
private static void TestBag()
{
Bag<int> bagOfInts = new Bag<int>();
bagOfInts.Add(1);
bagOfInts.Add(1);
bagOfInts.AddMany(new int[] { 1, 21 });
bagOfInts.AddRepresentative(1);
bagOfInts.ChangeNumberOfCopies(1, 3);
Console.WriteLine("CountWhere > 2 : " + bagOfInts.CountWhere(x => x > 2));
Console.WriteLine("Exists < 1 : " + bagOfInts.Exists(x => x < 1));
Console.WriteLine("Copies of 1 : " + bagOfInts.NumberOfCopies(1));
foreach (var item in bagOfInts)
{
Console.WriteLine(item);
}
Bag<Student> bagOfStudents = new Bag<Student>();
}