本文整理汇总了C#中LinkedList.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# LinkedList.FirstOrDefault方法的具体用法?C# LinkedList.FirstOrDefault怎么用?C# LinkedList.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList
的用法示例。
在下文中一共展示了LinkedList.FirstOrDefault方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DequeueFreeChild
private static QueueElement DequeueFreeChild(LinkedList<QueueElement> childrenQueue, QueueElement parentNode, int precedents)
{
QueueElement freeChild = childrenQueue
.FirstOrDefault(childNode =>
parentNode.Edges.Count(_ => _ == childNode.Node) <= 0);
if (freeChild == null) return null;
if (++freeChild.PrecedentCount == precedents)
childrenQueue.Remove(freeChild);
return freeChild;
}
示例2: TryGetManagedWindowForWorkspace
public bool TryGetManagedWindowForWorkspace(IntPtr hWnd, Workspace workspace,
out Window window, out LinkedList<Tuple<Workspace, Window>> list)
{
if (ApplicationsTryGetValue(hWnd, out list))
{
var tuple = list.FirstOrDefault(t => t.Item1 == workspace);
if (tuple != null)
{
window = tuple.Item2;
return true;
}
}
window = null;
return false;
}
示例3: GetCommandName
public static string GetCommandName([NotNull, ItemNotNull] ref IEnumerable<string> args)
{
#region Sanity checks
if (args == null) throw new ArgumentNullException(nameof(args));
#endregion
var arguments = new LinkedList<string>(args);
string commandName = arguments.FirstOrDefault(argument => !argument.StartsWith("-") && !argument.StartsWith("/"));
if (commandName != null) arguments.Remove(commandName);
args = arguments;
return commandName;
}
示例4: GetMessage
private static IrcMessage GetMessage(string unparsedMessage, LinkedList<IrcMessage> potentialHandlers)
{
IrcMessage msg = potentialHandlers.FirstOrDefault(m => m.CanParse(unparsedMessage));
if (msg != null)
{
// prioritize this IrcMessage by moving it to the beginning of the list
if (msg != potentialHandlers.First.Value)
{
potentialHandlers.Remove(msg);
potentialHandlers.AddFirst(msg);
}
// return a new instance of this message
return (IrcMessage) Activator.CreateInstance(msg.GetType());
}
return null;
}