| RankedSetT Constructor (IComparerT) |
Initializes a new set instance that uses the supplied comparer.
Namespace:
Kaos.Collections
Assembly:
KaosCollections (in KaosCollections.dll) Version: 4.2.0.0
Syntax Exceptions Examples
This program shows usage of a custom comparer for case insensitivity.
using System;
using Kaos.Collections;
namespace ExampleApp
{
class RsExample01
{
static bool IsPolynymous (string name) => name.Contains (" ");
static void Main()
{
var musicians = new RankedSet<string> (StringComparer.InvariantCultureIgnoreCase);
foreach (var m1 in new string[] { "Falco", "k.d. lang", "Madonna", "Tom Petty",
"Joni Mitchell", "Grimes", "Warren Zevon" })
musicians.Add (m1);
Console.WriteLine ("Candidates:");
foreach (var item in musicians)
Console.WriteLine ($" {item}");
musicians.Remove ("Falco");
musicians.RemoveWhere (IsPolynymous);
musicians.RemoveRange (1, musicians.Count-1);
Console.WriteLine ("\nFavorite:");
foreach (var item in musicians)
Console.WriteLine ($" {item}");
}
}
}
See Also