本文整理汇总了C#中HashSet.ExceptWith方法的典型用法代码示例。如果您正苦于以下问题:C# HashSet.ExceptWith方法的具体用法?C# HashSet.ExceptWith怎么用?C# HashSet.ExceptWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashSet
的用法示例。
在下文中一共展示了HashSet.ExceptWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public virtual InternalModelBuilder Apply(InternalModelBuilder modelBuilder)
{
Check.NotNull(modelBuilder, nameof(modelBuilder));
foreach (var entityType in modelBuilder.Metadata.GetEntityTypes())
{
var unmappedProperty = entityType.GetProperties().FirstOrDefault(p => !IsMappedPrimitiveProperty(((IProperty)p).ClrType));
if (unmappedProperty != null)
{
throw new InvalidOperationException(CoreStrings.PropertyNotMapped(unmappedProperty.Name, entityType.Name));
}
if (entityType.HasClrType())
{
var clrProperties = new HashSet<string>();
clrProperties.UnionWith(entityType.ClrType.GetRuntimeProperties()
.Where(pi => pi.IsCandidateProperty())
.Select(pi => pi.Name));
clrProperties.ExceptWith(entityType.GetProperties().Select(p => p.Name));
clrProperties.ExceptWith(entityType.GetNavigations().Select(p => p.Name));
var entityTypeBuilder = modelBuilder.Entity(entityType.ClrType, ConfigurationSource.Convention);
clrProperties.RemoveWhere(p => entityTypeBuilder.IsIgnored(p, ConfigurationSource.Convention));
if (clrProperties.Count > 0)
{
foreach (var clrProperty in clrProperties)
{
var actualProperty = entityType.ClrType.GetRuntimeProperty(clrProperty);
var targetType = FindCandidateNavigationPropertyType(actualProperty);
if (targetType != null)
{
if (!modelBuilder.IsIgnored(targetType.DisplayName(), ConfigurationSource.Convention))
{
throw new InvalidOperationException(CoreStrings.NavigationNotAdded(actualProperty.Name, entityType.Name));
}
}
else
{
throw new InvalidOperationException(CoreStrings.PropertyNotAdded(actualProperty.Name, entityType.Name));
}
}
}
}
}
return modelBuilder;
}
示例2: onProductListReceived
public void onProductListReceived (string productListString) {
Hashtable response = (Hashtable)MiniJSON.jsonDecode (productListString);
if (response.Count == 0) {
callback.logError (UnibillError.AMAZONAPPSTORE_GETITEMDATAREQUEST_NO_PRODUCTS_RETURNED);
callback.onSetupComplete (false);
return;
}
HashSet<PurchasableItem> productsReceived = new HashSet<PurchasableItem>();
foreach (var identifier in response.Keys) {
var item = remapper.getPurchasableItemFromPlatformSpecificId(identifier.ToString());
Hashtable details = (Hashtable) response[identifier];
PurchasableItem.Writer.setLocalizedPrice(item, (string) details["price"]);
PurchasableItem.Writer.setLocalizedTitle(item, (string) details["localizedTitle"]);
PurchasableItem.Writer.setLocalizedDescription(item, (string) details["localizedDescription"]);
productsReceived.Add(item);
}
HashSet<PurchasableItem> productsNotReceived = new HashSet<PurchasableItem> (db.AllPurchasableItems);
productsNotReceived.ExceptWith (productsReceived);
if (productsNotReceived.Count > 0) {
foreach (PurchasableItem product in productsNotReceived) {
this.unknownAmazonProducts.Add(remapper.mapItemIdToPlatformSpecificId(product));
callback.logError(UnibillError.AMAZONAPPSTORE_GETITEMDATAREQUEST_MISSING_PRODUCT, product.Id, remapper.mapItemIdToPlatformSpecificId(product));
}
}
callback.onSetupComplete(true);
}
示例3: Visit
public override void Visit(AST.MethodDeclNode node)
{
MethodBeingVisited = ClassBeingVisited.Methods.Lookup(node.methodName.name);
if (node.paramDeclList != null)
foreach (AST.ParamDeclNode paramDecl in node.paramDeclList)
paramDecl.Accept(this);
if (node.variableDeclList != null)
foreach (AST.VariableDeclNode variableDecl in node.variableDeclList)
variableDecl.Accept(this);
if (node.statementList != null)
{
var reverseList = node.statementList.statementList;
reverseList.Reverse();
HashSet<AST.IdentifierNode> afterLiveness = new HashSet<AST.IdentifierNode>();
foreach (AST.StatementNode statement in reverseList)
{
m_R.Clear();
m_W.Clear();
statement.Accept(this);
afterLiveness.ExceptWith(m_W);
afterLiveness.UnionWith(m_R);
m_livenessAtNode[statement] = new HashSet<AST.IdentifierNode>(afterLiveness);
}
}
}
示例4: EntityJoinOperation
public EntityJoinOperation(Process process, Relationship rel)
: base(process) {
_rel = rel;
var rightFields = new HashSet<string>(rel.RightEntity.OutputFields().Aliases());
rightFields.ExceptWith(rel.LeftEntity.OutputFields().Aliases());
_fields = rightFields.ToArray();
}
示例5: Start
/// <summary>
/// start
/// </summary>
public override void Start()
{
if (this._config.Discovery != null &&
this._config.Discovery.Zookeeper != null &&
!string.IsNullOrEmpty(this._config.Discovery.Zookeeper.ConfigPath) &&
!string.IsNullOrEmpty(this._config.Discovery.Zookeeper.ConfigName) &&
!string.IsNullOrEmpty(this._config.Discovery.Zookeeper.ZNode))
{
this._zkDiscovery = new ZoomkeeperDiscovery(this._config.Client,
this._config.Discovery.Zookeeper.ConfigPath,
this._config.Discovery.Zookeeper.ConfigName,
this._config.Discovery.Zookeeper.ZNode, endpoints =>
{
lock (this._lockObj)
{
var set = new HashSet<string>(this.GetAllRegisteredEndPoint().Select(c => c.Key).Distinct().ToArray());
set.ExceptWith(endpoints.Select(p =>
string.Concat(p.Address.ToString(), ":", p.Port.ToString())).Distinct().ToArray());
if (set.Count > 0)
{
foreach (var name in set) this.UnRegisterEndPoint(name);
}
foreach (var p in endpoints)
this.TryRegisterEndPoint(string.Concat(p.Address.ToString(), ":", p.Port.ToString()), new EndPoint[] { p });
}
});
}
base.Start();
}
示例6: WalkGrammar
public override void WalkGrammar(Grammar grammar)
{
var rules = grammar.Rules.ToDictionary(r => r.Identifier.Name, r => r);
var startRule = grammar.Settings.Where(s => s.Key.Name == "start").Select(s => s.Value.ToString()).SingleOrDefault() ?? grammar.Rules[0].Identifier.Name;
this.usedRules.Add(startRule);
this.rulesToVisit.Enqueue(startRule);
var publicRules = grammar.Rules.Where(r => r.Flags.Any(f => f.Name == "public" || f.Name == "export"));
foreach (var rule in publicRules)
{
if (this.usedRules.Add(rule.Identifier.Name))
{
this.rulesToVisit.Enqueue(rule.Identifier.Name);
}
}
while (this.rulesToVisit.Count > 0)
{
var ruleName = this.rulesToVisit.Dequeue();
this.WalkRule(rules[ruleName]);
}
var unusedRules = new HashSet<string>(grammar.Rules.Select(r => r.Identifier.Name));
unusedRules.ExceptWith(this.usedRules);
foreach (var ruleName in unusedRules)
{
var rule = rules[ruleName];
this.result.AddCompilerError(rule.Identifier.Start, () => Resources.PEG0017_WARNING_UnusedRule, rule.Identifier.Name);
}
}
示例7: DeleteInDestination
private async Task DeleteInDestination(HashSet<Tuple<string, string, string>> src,
HashSet<Tuple<string, string, string>> dst)
{
dst.ExceptWith(src);
int n = 0;
// group by table + partition
foreach (var batch1 in dst.GroupBy(x => x.Item1 + x.Item2))
{
CloudTable dstTable = _dstClient.GetTableReference(batch1.First().Item1);
if (_token.IsCancellationRequested)
return;
foreach (var batch2 in batch1.Batch(100))
{
if (_token.IsCancellationRequested)
return;
var op = new TableBatchOperation();
foreach (var tuple in batch2)
{
op.Delete(new TableEntity(tuple.Item2, tuple.Item3) {ETag = "*"});
}
await dstTable.ExecuteBatchAsync(op, _token);
n += Math.Min(op.Count, 100);
Console.WriteLine("deleted {0} rows", n);
}
}
}
示例8: Main
static void Main(string[] args)
{
var letters = new HashSet<char>("the quick brown fox");
Console.WriteLine(letters.Contains('t')); // true
Console.WriteLine(letters.Contains('j')); // false
foreach (char c in letters)
{
Console.Write(c); // the quickbrownfx
}
letters.IntersectWith("aeiou");
foreach (char c in letters)
{
Console.Write(c); // euio
}
var letters2 = new HashSet<char>("the quick brown fox");
letters2.ExceptWith("aeiou");
foreach (char c in letters2)
{
Console.Write(c); // th qckbrwnfx
}
var letters3 = new HashSet<char>("the quick brown fox");
letters3.SymmetricExceptWith("the lazy brown fox");
foreach (char c in letters3)
{
Console.Write(c); // quicklazy
}
}
示例9: Start
/// <summary>
/// start
/// </summary>
public void Start()
{
if (this._config == null || this._config.Discovery == null ||
this._config.Discovery.Zookeeper == null || string.IsNullOrEmpty(this._config.Discovery.Zookeeper.ZNode)) return;
var keeperConfig = this._config.Discovery.Zookeeper;
var zk = ZookClientPool.Get(keeperConfig.ConfigPath, "zookeeper", keeperConfig.ConfigName);
//ensure root node...
var nodes = new NodeInfo[2];
nodes[0] = new NodeInfo(string.Concat("/", keeperConfig.ZNode), null, IDs.OPEN_ACL_UNSAFE, CreateModes.Persistent);
nodes[1] = new NodeInfo(string.Concat("/", keeperConfig.ZNode, "/consumers"), null, IDs.OPEN_ACL_UNSAFE, CreateModes.Persistent);
NodeFactory.TryEnsureCreate(zk, nodes, () =>
{
var currProcess = Process.GetCurrentProcess();
var path = string.Concat("/", keeperConfig.ZNode, "/consumers/", Uri.EscapeDataString(string.Format(
"consumer://{0}/{1}?application={2}&category=consumers&check=false&dubbo=2.5.1&interface={1}&methods={6}&owner={3}&pid={4}&revision=0.0.2-SNAPSHOT&side=consumer×tamp={5}",
IPUtility.GetLocalIntranetIP().ToString(),
keeperConfig.ZNode,
currProcess.ProcessName,
string.Empty,
currProcess.Id.ToString(),
Date.ToMillisecondsSinceEpoch(DateTime.UtcNow).ToString(),
this._methods)));
this._sessionNode = new SessionNode(zk, path, null, IDs.OPEN_ACL_UNSAFE);
});
this._watcher = new ChildrenWatcher(zk, string.Concat("/", keeperConfig.ZNode, "/providers"), (names) =>
{
//已存在的servers
var arrExistServers = this._thriftClient.GetAllNodeNames();
//当前从zk获取到servers
var arrNowServers = names.Select(s =>
{
var t = Uri.UnescapeDataString(s);
t = t.Substring(t.IndexOf(":") + 3);
return t.Substring(0, t.IndexOf("/"));
}).ToArray();
var set = new HashSet<string>(arrExistServers);
set.ExceptWith(arrNowServers);
if (set.Count > 0)
{
foreach (var child in set) this._thriftClient.UnRegisterServerNode(child);
}
set = new HashSet<string>(arrNowServers);
set.ExceptWith(arrExistServers);
if (set.Count > 0)
{
foreach (var child in set)
{
int index = child.IndexOf(":");
this._thriftClient.RegisterServerNode(child,
new IPEndPoint(IPAddress.Parse(child.Substring(0, index)), int.Parse(child.Substring(index + 1))));
}
}
});
}
示例10: GetEdgesBetween
/// <summary>
/// Returns all Edges that connect the two nodes (which are assumed to be different).
/// </summary>
/// <param name="node0"></param>
/// <param name="node1"></param>
/// <returns></returns>
public static IList<DirectedEdge> GetEdgesBetween(Node node0, Node node1)
{
IList<Edge> edges0 = DirectedEdge.ToEdges(node0.OutEdges.Edges);
var commonEdges = new HashSet<DirectedEdge>(Utilities.Caster.Cast<DirectedEdge>(edges0));
IList<Edge> edges1 = DirectedEdge.ToEdges(node1.OutEdges.Edges);
commonEdges.ExceptWith(Utilities.Caster.Cast<DirectedEdge>(edges1));
return new List<DirectedEdge>(commonEdges);
}
示例11: GetCommands
public IEnumerable<string> GetCommands(string profile)
{
var commands = new HashSet<string>(_requirements.SelectMany(x => x.Commands));
var removeCommands = _remove.Where(x => x.Profile == profile)
.SelectMany(x => x.Commands).ToArray();
commands.ExceptWith(removeCommands);
return commands;
}
示例12: SynchronizeModelChildren
protected void SynchronizeModelChildren()
{
HashSet<object> set = new HashSet<object>(ModelChildren);
Children.RemoveAll(n => !set.Contains(n.Model));
set.ExceptWith(Children.Select(n => n.Model));
InsertChildren(set);
if (IsSpecialNode())
InsertSpecialNodes();
}
示例13: GetSurroundingCells
public Cell[] GetSurroundingCells()
{
HashSet<Cell> surrounding = new HashSet<Cell>();
foreach (var member in members)
foreach (var move in MoveTypeExt.LinearMoves)
surrounding.Add(member.Move(move));
surrounding.ExceptWith(members);
return surrounding.ToArray();
}
示例14: GetUnusedRules
public IEnumerable<IStylingRule> GetUnusedRules()
{
lock (_sync)
{
var unusedRules = new HashSet<IStylingRule>(GetAllRules());
unusedRules.ExceptWith(_ruleUsages.Select(x => x.Rule).Distinct());
return unusedRules.Where(x => !UsageRegistry.IsAProtectedClass(x)).ToList();
}
}
示例15: FindModulesAsync
/// <summary>
/// Determines whether the interpreter factory contains the specified
/// modules.
/// </summary>
/// <returns>The names of the modules that were found.</returns>
public static async Task<HashSet<string>> FindModulesAsync(this IPythonInterpreterFactory factory, params string[] moduleNames) {
var finding = new HashSet<string>(moduleNames);
var found = new HashSet<string>();
var withPackages = factory.PackageManager;
if (withPackages != null) {
foreach (var m in finding) {
if ((await withPackages.GetInstalledPackageAsync(new PackageSpec(m), CancellationToken.None)).IsValid) {
found.Add(m);
}
}
finding.ExceptWith(found);
if (!finding.Any()) {
// Found all of them, so stop searching
return found;
}
}
var withDb = factory as PythonInterpreterFactoryWithDatabase;
if (withDb != null && withDb.IsCurrent) {
var db = withDb.GetCurrentDatabase();
found.UnionWith(finding.Where(m => db.GetModule(m) != null));
// Always stop searching after this step
return found;
}
if (withDb != null) {
try {
var paths = await PythonTypeDatabase.GetDatabaseSearchPathsAsync(withDb);
found.UnionWith(PythonTypeDatabase.GetDatabaseExpectedModules(withDb.Configuration.Version, paths)
.SelectMany()
.Select(g => g.ModuleName)
.Where(m => finding.Contains(m)));
} catch (InvalidOperationException) {
}
finding.ExceptWith(found);
if (!finding.Any()) {
// Found all of them, so stop searching
return found;
}
}
return await Task.Run(() => {
foreach (var mp in ModulePath.GetModulesInLib(factory.Configuration)) {
if (finding.Remove(mp.ModuleName)) {
found.Add(mp.ModuleName);
}
if (!finding.Any()) {
break;
}
}
return found;
});
}