本文整理汇总了C#中ISet.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# ISet.ToList方法的具体用法?C# ISet.ToList怎么用?C# ISet.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISet
的用法示例。
在下文中一共展示了ISet.ToList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TermExpression
public TermExpression(ISet<TermExpression> terms)
{
if (terms == null || terms.Count == 0)
throw new CqlLinqException("Empty lists are not allowed");
_type = typeof(ISet<>).MakeGenericType(terms.First().Type);
_terms = terms.ToList().AsReadOnly();
_termType = CqlExpressionType.Set;
}
示例2: FetchTopicMetadata
/// <summary>
/// Used by the producer to send a metadata request since it has access to the ProducerConfig
/// </summary>
/// <param name="topics">The topics for which the metadata needs to be fetched</param>
/// <param name="brokers">The brokers in the cluster as configured on the client</param>
/// <param name="producerConfig">The producer's config</param>
/// <param name="correlationId">topic metadata response</param>
/// <returns></returns>
public static TopicMetadataResponse FetchTopicMetadata(
ISet<string> topics, IList<Broker> brokers, ProducerConfig producerConfig, int correlationId)
{
var fetchMetaDataSucceeded = false;
var i = 0;
var topicMetadataRequest = new TopicMetadataRequest(
TopicMetadataRequest.CurrentVersion, correlationId, producerConfig.ClientId, topics.ToList());
TopicMetadataResponse topicMetadataResponse = null;
Exception t = null;
// shuffle the list of brokers before sending metadata requests so that most requests don't get routed to the same broker
var shuffledBrokers = brokers.Shuffle();
while (i < shuffledBrokers.Count() && !fetchMetaDataSucceeded)
{
var producer = ProducerPool.CreateSyncProducer(producerConfig, shuffledBrokers[i]);
Logger.InfoFormat("Fetching metadata from broker {0} with correlation id {1} for {2} topic(s) {3}", shuffledBrokers[i], correlationId, topics.Count, string.Join(",", topics));
try
{
topicMetadataResponse = producer.Send(topicMetadataRequest);
fetchMetaDataSucceeded = true;
}
catch (Exception e)
{
Logger.Warn(string.Format("Fetching topic metadata with correlation id {0} for topic [{1}] from broker [{2}] failed", correlationId, topics, shuffledBrokers[i]), e);
t = e;
}
finally
{
i++;
producer.Dispose();
}
}
if (!fetchMetaDataSucceeded)
{
throw new KafkaException(
string.Format(
"fetching topic metadata for topics [{0}] from broker [{1}] failed", string.Join(",", topics), string.Join(", ", shuffledBrokers)),
t);
}
Logger.DebugFormat("Successfully fetched metadata for {0} topic(s) {1}", topics.Count(), string.Join(",", topics));
return topicMetadataResponse;
}
示例3: LadderLengthRecur
public int LadderLengthRecur(string beginWord, string endWord, ISet<string> wordList, HashSet<string> eSet)
{
int diff = scmp(beginWord, endWord);
if (diff == 0)
return 1;
else if (diff == 1)
return 2;
List<string> lt = wordList.ToList();
int minval = 0;
foreach (var item in lt)
{
if (scmp(item, beginWord) == 1 && !eSet.Contains(item))
{
wordList.Remove(item);
eSet.Add(item);
int val = LadderLengthRecur(item, endWord, wordList, eSet);
if (val != 0)
{
if (minval == 0)
minval = val;
else if (minval > val)
minval = val;
if (minval == 2)
return 3;
}
eSet.Remove(item);
wordList.Add(item);
}
}
if (minval == 0)
return 0;
return minval + 1;
}
示例4: GetAllModelTypes
static IEnumerable<Type> GetAllModelTypes(ISet<Type> allModelTypes)
{
foreach (var modelType in allModelTypes.ToList())
{
GetPropertyModelTypes(modelType, allModelTypes);
}
return allModelTypes;
}
示例5: LayOutSiblingNodes
public static List<Node> LayOutSiblingNodes(ISet<Node> toBeGrouped)
{
if (toBeGrouped.Count <= 1)
return toBeGrouped.ToList();
var groupedNodes = new List<Node>();
var hasBeenAdded = new HashSet<Node>();
var nextGroupTarget = toBeGrouped;
//Remove nodes that does not depend on anything and is never referenced
var unreferenced = toBeGrouped.Where(x => !x.SiblingDependencies.Any()
&& !toBeGrouped.SiblingDependencies().Contains(x)).ToHashSet();
nextGroupTarget.ExceptWith(unreferenced);
while (toBeGrouped.Any())
{
if (!nextGroupTarget.Any())
{
nextGroupTarget = toBeGrouped;
}
while (nextGroupTarget.Any())
{
var currentLayer = GetFacadeNodes(nextGroupTarget);
nextGroupTarget = currentLayer.SiblingDependencies().ToHashSet();
if (nextGroupTarget.Any())
{
//Get the next layer to check if any of the dependencies are unique to a node of the current layer
var nextLayer = GetFacadeNodes(nextGroupTarget);
//Check if any nodes that have not been added yet has dependencies on the unique ones, in this case they arent really unique
var leftForNextBatch = toBeGrouped.Except(currentLayer.Union(nextLayer));
nextLayer.RemoveAll(x => leftForNextBatch.SiblingDependencies().Contains(x));
var uniqueDependencies =
nextLayer.Where(x => !currentLayer.All(n => n.SiblingDependencies.Contains(x)))
.Distinct()
.ToList();
//If there are unique dependencies, vertical layers are created to separate the unique dependency from layers that dont depend on it
if (uniqueDependencies.Any())
{
while (true)
{
//Check if any nodes that have not been added yet has dependencies on the unique ones, in this case they arent really unique
leftForNextBatch = toBeGrouped.Except(currentLayer.Union(nextLayer));
nextLayer.RemoveAll(x => leftForNextBatch.Any(y => y.IndirectlyDependsOn(x)));
var groupsToCreate = FindDependencyPatterns(currentLayer, nextLayer);
var toBeShared = new HashSet<Node>();
toBeGrouped.ExceptWith(currentLayer);
foreach (var dependencyGroup in groupsToCreate)
{
var referencers = dependencyGroup.Referencers;
currentLayer.RemoveRange(referencers.ToList());
var dependants = dependencyGroup.Dependants.ToList();
nextGroupTarget.ExceptWith(dependants);
toBeGrouped.ExceptWith(dependants);
hasBeenAdded.UnionWith(dependants);
hasBeenAdded.UnionWith(referencers);
// Add dependant to the vertical layer
var depNode = CreateHorizontalLayer(dependants);
// Add references to the vertical layer
var referenceNode = CreateHorizontalLayer(referencers);
var newList = new List<Node> {depNode, referenceNode};
//Get ALL the possible candidates for the vertical layer
var verticalCandidates =
referencers.SelectMany(x => x.IndirectSiblingDependencies())
.Except(dependants)
.Union(
dependants.SelectMany(x => x.IndirectSiblingDependencies()))
.Distinct()
.Except(hasBeenAdded).Intersect(toBeGrouped)
.ToHashSet();
//Get all the nodes in this current call depth
var otherGroups = groupsToCreate.Except(dependencyGroup);
var nodesInOtherGroups = otherGroups.
SelectMany(x => x.Dependants.Union(x.Referencers)).ToHashSet();
var otherNodes =
toBeGrouped.Union(currentLayer)
.Union(nodesInOtherGroups)
.Except(verticalCandidates)
.ToHashSet();
var siblingDepsRelevantForNewNode = new HashSet<Node>();
//If any of the other nodes depends on the vertical candidate the candidate is removed and will be placed in a later iteration of this call (it is still left in toBeGrouped)
foreach (var candidate in verticalCandidates.ToList())
{
var otherNodesDependantOnCandidate =
otherNodes.Where(x => x.IndirectlyDependsOn(candidate)).ToHashSet();
if (toBeShared.Contains(candidate) || otherNodesDependantOnCandidate.Any())
{
verticalCandidates.Remove(candidate);
toBeShared.Add(candidate);
}
}
if (verticalCandidates.Any())
{
toBeGrouped.ExceptWith(verticalCandidates);
nextGroupTarget.ExceptWith(verticalCandidates);
hasBeenAdded.UnionWith(verticalCandidates);
//.........这里部分代码省略.........
示例6: EClosure
internal IList<NFAState> EClosure(ISet<NFAState> closureStates)
{
return EClosure(closureStates.ToList());
}