本文整理汇总了C#中IReadOnlyCollection.ElementAt方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyCollection.ElementAt方法的具体用法?C# IReadOnlyCollection.ElementAt怎么用?C# IReadOnlyCollection.ElementAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReadOnlyCollection
的用法示例。
在下文中一共展示了IReadOnlyCollection.ElementAt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: selectMember
public void selectMember(IReadOnlyCollection<Member> list)
{
int choice = int.Parse(c.GetUserInput());
if (choice == 0)
{
return;
}
choice--;
Member member = list.ElementAt(choice);
c.showMember(member);
int menuChoice = int.Parse(c.GetUserInput());
switch (menuChoice)
{
case 1://remove member
mDAL.removeMemberFromList(choice);
break;
case 2://change first name
member.FirstName = c.GetUserInput();
break;
case 3://change last name
member.LastName = c.GetUserInput();
break;
case 4://change ssn
member.SSN = c.GetUserInput();
break;
case 5://add a boat
c.showBoatTypes();
int typeChoice = int.Parse(c.GetUserInput());
c.boatLengthPrompt();
double lengthInput = double.Parse(c.GetUserInput());
b = new Boat(typeChoice-1, lengthInput);
member.AddBoat(b);
break;
case 6://view boats
c.chooseBoatPrompt();
c.showMemberBoats(member);
updateBoat(member);
break;
default:
break;
}
}
示例2: CheckForNewChat
private void CheckForNewChat(IReadOnlyCollection<IWebElement> elemChatWindows)
{
for (int i = 0; i < elemChatWindows.Count; i++) {
string sID = GetProfileLink(elemChatWindows.ElementAt(i));
if (sID == null) {
continue;
}
if (!windows.ContainsKey(sID)) {
CWindow window = new CWindow(this, replier.Whitelist, elemChatWindows.ElementAt(i));
window.SetReplyMode(new CInherit());
window.ChatMsgReceived += window_ChatMsgReceived;
CDebug.Print("Added a new chat: " + window.ChatName, ConsoleColor.Green);
windows.Add(sID, window);
if (ChatAdded != null) {
ChatAdded(window);
}
this.replier.ChatAdded_(window);
}
}
}
示例3: CheckForClosedChat
private void CheckForClosedChat(IReadOnlyCollection<IWebElement> elemChatWindows)
{
List<string> exist = windows.Keys.ToList();
for (int i = 0; i < elemChatWindows.Count; i++) {
string sID = GetProfileLink(elemChatWindows.ElementAt(i));
if (exist.Contains(sID)) {
exist.Remove(sID);
}
}
for (int i = 0; i < exist.Count; i++) {
CWindow target = windows[exist[i]];
CDebug.Print("Removed a chat: " + target.ChatName, ConsoleColor.Red);
target.Stop();
if (ChatRemoved != null) {
ChatRemoved(target);
}
this.replier.ChatRemoved_(target);
windows.Remove(exist[i]);
}
}
示例4: SmoothPath
private List<Node> SmoothPath(IReadOnlyCollection<Node> path)
{
var currentNode = path.Last();
var smoothPath = new List<Node> {currentNode};
for (var i = path.Count - 2; i >= 0; i--)
{
if (!IsValidNode(path.ElementAt(i), currentNode))
{
smoothPath.Add(path.ElementAt(i + 1));
currentNode = path.ElementAt(i + 1);
}
}
smoothPath.Add(path.First());
return smoothPath;
}
示例5: SetAgents
public void SetAgents(IReadOnlyCollection<TestAgent> agents)
{
var tests = Plan.Cases.Actives().ToList();
int pageSize = (int)Math.Ceiling((double)tests.Count / agents.Count);
int pageCount = (int)Math.Ceiling((double)tests.Count / pageSize);
for (int i = 0; i < pageCount; i++)
{
Queues.Add(new TestQueue
{
Agent = agents.ElementAt(i),
Runs = new HashSet<TestRun>(tests.Skip(i * pageSize).Take(pageSize).Select(z => new TestRun { Case = z }))
});
}
}
示例6: selectMember
// argument Listan
public void selectMember(IReadOnlyCollection<Member> list)
{
ConsoleView test = new ConsoleView();
// show menyn
int choice = int.Parse(Console.ReadLine());
if(choice == 0)
{
return;
}
choice--;
Member member = list.ElementAt(choice);
test.ShowMembers(member); // skickar till show member visning av medlemmar
int menuChoicce = int.Parse(Console.ReadLine());
switch (menuChoicce) // menualternativ för Medlemmen
{
case 0:
return;
case 1:
member.GetName = test.Rename(); // change name
break;
case 2:
MemberDAL.removeMember(choice); // tas bort medlemmen
break;
case 3:
member.GetSecurityNumber = test.ChangeNumber(); // ändra personlighets nummer
break;
case 4:
test.ViewBoattype();
int Boatchoice = int.Parse(test.Boattypeinfo()); // användning av inmatning av boatchoice
double BoatLength = double.Parse(test.BoattypeLength()); //inmatning båtlängd // kan inte använda console write line eftersom det är void
Boat FullBoat = new Boat(Boatchoice,BoatLength); // instans av ny objekt( med intagen längd av båtlängd och båtkategorier
member.sendToBoatList(FullBoat);
break;
case 5:
test.ShowBoat(member);
selectBoat(member);
break;
default: break;
}
}
示例7: CountMinSketch
private static Dictionary<string, int> CountMinSketch(IReadOnlyCollection<string> listOfM, int k, int t)
{
var counterMatrix = new Matrix(t, k);
//map it out first
var mMap = new Dictionary<string, int>();
var distinctM = listOfM.Distinct().ToList();
for (var i = 0; i < distinctM.Count; i++)
{
mMap[distinctM[i]] = i;
}
var hashFunctions = HashUtil.HashFunctions(t, k, mMap.Keys.Count).ToList();
for (var i = 0; i < listOfM.Count; i++)
{
var mapResult = mMap[listOfM.ElementAt(i)];
for (var j = 0; j < t; j++)
{
var hashFunctionResult = hashFunctions[j][mapResult];
counterMatrix.SetValue(hashFunctionResult, j,
counterMatrix.GetValue(hashFunctionResult, j) + 1
);
}
}
var resultDictionary = new Dictionary<string, int>();
foreach(var kvp in mMap)
{
var minResult = int.MaxValue;
for (var i = 0; i < t; i++)
{
var hashMap = hashFunctions[i][kvp.Value];
var tempResult = counterMatrix.GetValue(hashMap, i);
if (tempResult < minResult)
{
minResult = tempResult;
}
}
resultDictionary[kvp.Key] = minResult;
}
return resultDictionary;
}
示例8: VerifyDiagnosticResults
/// <summary>
/// Checks each of the actual Diagnostics found and compares them with the corresponding DiagnosticResult in the array of expected results.
/// Diagnostics are considered equal only if the DiagnosticResultLocation, Id, Severity, and Message of the DiagnosticResult match the actual diagnostic.
/// </summary>
/// <param name="actualResults">The Diagnostics found by the compiler after running the analyzer on the source code</param>
/// <param name="analyzer">The analyzer that was being run on the sources</param>
/// <param name="expectedResults">Diagnostic Results that should have appeared in the code</param>
private static void VerifyDiagnosticResults(IReadOnlyCollection<Diagnostic> actualResults, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expectedResults)
{
var expectedCount = expectedResults.Length;
var actualCount = actualResults.Count;
if (expectedCount != actualCount)
{
var diagnosticsOutput = actualResults.Any() ? FormatDiagnostics(analyzer, actualResults.ToArray()) : " NONE.";
Assert.IsTrue(false, $"Mismatch between number of diagnostics returned, expected \"{expectedCount}\" actual \"{actualCount}\"\r\n\r\nDiagnostics:\r\n{diagnosticsOutput}\r\n");
}
for (var i = 0; i < expectedResults.Length; i++)
{
var actual = actualResults.ElementAt(i);
var expected = expectedResults[i];
if (expected.Line == -1 && expected.Column == -1)
{
if (actual.Location != Location.None)
{
Assert.IsTrue(false, $"Expected:\nA project diagnostic with No location\nActual:\n{FormatDiagnostics(analyzer, actual)}");
}
}
else
{
VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Locations.First());
var additionalLocations = actual.AdditionalLocations.ToArray();
if (additionalLocations.Length != expected.Locations.Length - 1)
{
Assert.IsTrue(false, $"Expected {expected.Locations.Length - 1} additional locations but got {additionalLocations.Length} for Diagnostic:\r\n {FormatDiagnostics(analyzer, actual)}\r\n");
}
for (var j = 0; j < additionalLocations.Length; ++j)
{
VerifyDiagnosticLocation(analyzer, actual, additionalLocations[j], expected.Locations[j + 1]);
}
}
if (actual.Id != expected.Id)
{
Assert.IsTrue(false, $"Expected diagnostic id to be \"{expected.Id}\" was \"{actual.Id}\"\r\n\r\nDiagnostic:\r\n {FormatDiagnostics(analyzer, actual)}\r\n");
}
if (actual.Severity != expected.Severity)
{
Assert.IsTrue(false, $"Expected diagnostic severity to be \"{expected.Severity}\" was \"{actual.Severity}\"\r\n\r\nDiagnostic:\r\n {FormatDiagnostics(analyzer, actual)}\r\n");
}
if (actual.GetMessage() != expected.Message)
{
Assert.IsTrue(false, $"Expected diagnostic message to be \"{expected.Message}\" was \"{actual.GetMessage()}\"\r\n\r\nDiagnostic:\r\n {FormatDiagnostics(analyzer, actual)}\r\n");
}
}
}