本文整理汇总了C#中Set.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# Set.Delete方法的具体用法?C# Set.Delete怎么用?C# Set.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set.Delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteTest
public void DeleteTest()
{
Set<int> set = new Set<int>();
set.Add(3);
set.Delete(3);
Assert.IsFalse(set.Contain(3));
Assert.IsFalse(set.Delete(3));
}
示例2: SetTest
public void SetTest()
{
var set = new Set<int>();
set.Add(2);
Assert.IsTrue(set.Contains(2));
set.Delete(2);
Assert.IsFalse(set.Contains(2));
}
示例3: DeletePositiveTest
public void DeletePositiveTest()
{
ISet<string> sets = new Set<string>();
sets.Add("item1");
sets.Add("item2");
sets.Delete("item1");
Assert.AreEqual(1, sets.Count);
}
示例4: GluedPolyline
static IEnumerable<Point> GluedPolyline(Station[] metroline, Dictionary<Station, Station> gluedMap) {
int i;
var ret = new Stack<Station>();
ret.Push(metroline[0]);
var seenStations = new Set<Station>();
for (i = 1; i < metroline.Length - 1; i++) {
var station = Glued(metroline[i], gluedMap);
if (seenStations.Contains(station)) {
//we made a cycle - need to cut it out
while (ret.Peek() != station)
seenStations.Delete(ret.Pop());
continue;
}
if (ApproximateComparer.Close(station.Position, ret.Peek().Position))
continue;
seenStations.Insert(station);
ret.Push(station);
}
ret.Push(metroline[i]);
return ret.Reverse().Select(n => n.Position);
}