本文整理汇总了C#中Common.List.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# List.Remove方法的具体用法?C# List.Remove怎么用?C# List.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common.List
的用法示例。
在下文中一共展示了List.Remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SmartDefense
private void SmartDefense(TurnInfo turn)
{
var unassigned = new List<Player>(turn.Own.Players);
unassigned.Remove(_ballOwner.Apply(turn, unassigned));
unassigned.Remove(_pickup.Apply(turn, unassigned));
unassigned.Remove(_catchUp.Apply(turn, unassigned));
unassigned.Remove(_keeper.Apply(turn, unassigned));
unassigned.Remove(_sweeper.Apply(turn, unassigned));
unassigned.Remove(_defender.Apply(turn, unassigned));
unassigned.Remove(_defender.Apply(turn, unassigned));
unassigned.Remove(_defender.Apply(turn, unassigned));
}
示例2: Gen
public static void Gen(IEnumerable<decimal> dSource, IEnumerable<int> dAvailable, List<int> dUsed, List<decimal> accessible)
{
foreach (var ds in dSource.Distinct())
{
foreach (var da in dAvailable.Except(dUsed))
{
dUsed.Add(da);
if (dUsed.Count == dAvailable.Count())
{
// end step
accessible.Add(ds * da);
accessible.Add(ds / da);
if (ds != 0) accessible.Add(da / ds);
accessible.Add(ds + da);
accessible.Add(ds - da);
accessible.Add(da - ds);
} else
{
// recourse ahead
Gen(dSource.Select(x => x * da), dAvailable, dUsed, accessible);
Gen(dSource.Select(x => x / da), dAvailable, dUsed, accessible);
Gen(dSource.Where(x => x != 0).Select(x => da / x), dAvailable, dUsed, accessible);
Gen(dSource.Select(x => x + da), dAvailable, dUsed, accessible);
Gen(dSource.Select(x => x - da), dAvailable, dUsed, accessible);
Gen(dSource.Select(x => da - x), dAvailable, dUsed, accessible);
}
dUsed.Remove(da);
}
}
}
示例3: GetVendorItems
public static List<Creature_vendor> GetVendorItems(uint Entry)
{
if (!_Vendors.ContainsKey(Entry))
{
Log.Info("WorldMgr", "Loading Vendors of " + Entry +" ...");
IList<Creature_vendor> IVendors = Database.SelectObjects<Creature_vendor>("Entry="+Entry);
List<Creature_vendor> Vendors = new List<Creature_vendor>();
Vendors.AddRange(IVendors);
_Vendors.Add(Entry, Vendors);
foreach (Creature_vendor Info in Vendors.ToArray())
{
if ((Info.Info = GetItem_Info(Info.ItemId)) == null)
{
Vendors.Remove(Info);
continue;
}
foreach (KeyValuePair<uint, UInt16> Kp in Info.ItemsReq)
{
Item_Info Req = GetItem_Info(Kp.Key);
if (Req != null)
Info.ItemsReqInfo.Add(Kp.Value, Req);
}
}
Log.Success("LoadCreatureVendors", "Loaded " + Vendors.Count + " Vendors of " + Entry);
}
return _Vendors[Entry];
}
示例4: RemoveIgnoredExtensions
private void RemoveIgnoredExtensions(object _params)
{
List<string> extensions = null;
string extension = _params as string;
if (extension != null)
{
extensions = new List<string> { extension };
}
else
{
IList items = (IList)_params;
extensions = items.Cast<string>().ToList();
}
Debug.Assert(extensions != null);
var ignoredExtensions = new List<string>(Settings.Default.IgnoredExtensions);
foreach (var ext in extensions)
{
extension = ext.ToLowerInvariant();
Debug.Assert(ignoredExtensions.Contains(extension));
ignoredExtensions.Remove(extension);
}
Settings.Default.IgnoredExtensions = ignoredExtensions;
Settings.Default.Save();
}
示例5: MergeOverlappingBlobs
/// <summary>
/// Merges overlapping blobs in a list of blobs.
/// </summary>
/// <param name="blobs">A list of blobs</param>
/// <returns>The list of blobs with overlapping blobs merged into single blobs.</returns>
protected virtual IList<IBlob> MergeOverlappingBlobs(IEnumerable<IBlob> blobs)
{
List<IBlob> mergedBlobs = new List<IBlob>();
Queue<IBlob> blobQueue = new Queue<IBlob>();
foreach (var blob in blobs)
{
blobQueue.Enqueue(blob);
}
while(blobQueue.Count > 0)
{
IBlob currBlob = blobQueue.Dequeue();
bool mergedBlob = false;
foreach (var blob in mergedBlobs)
{
Rectangle currRect = new Rectangle(currBlob.Position, currBlob.Dimension);
Rectangle blobRect = new Rectangle(blob.Position, blob.Dimension);
if (!currRect.IntersectsWith(blobRect))
{
continue;
}
MergedBlob mBlob = new MergedBlob(currBlob);
mBlob.AddBlob(blob);
mergedBlobs.Remove(blob);
blobQueue.Enqueue(mBlob);
mergedBlob = true;
break;
}
if (!mergedBlob)
{
mergedBlobs.Add(currBlob);
}
}
return mergedBlobs;
}
示例6: NetworkPollingAction
//.........这里部分代码省略.........
{
// При срабатывании по таймауту обновляем данные из удалённых устройтств
// При условии что контроллер в активном состоянии
foreach (DeviceBase device in _devices)
{
ReadDeviceParameters(device);
}
}
// Выполняем все запросы в буфере
while (_outputBuffer.Count > 0)
{
lock (_syncRoot)
{
networkRequest = _outputBuffer.Dequeue();
if (Status != Status.Running)
{
networkRequest.CurrentTransaction.Start();
networkRequest.CurrentTransaction.Abort(
new TransactionError
{
ErrorCode = TransactionErrorCodes.DataLinkPortNotInstalled,
Description = "Невозможно выполенить запрос. Не установлен контроллер сети"
});
networkRequest.AsyncRequestResult.SetCompleted();
continue;
}
}
if (cancel.IsCancellationRequested)
{
networkRequest.CurrentTransaction.Start();
networkRequest.CurrentTransaction.Abort(new TransactionError
{
ErrorCode = TransactionErrorCodes.RequestWasCancelled,
Description = "Выполнение запроса прервано по требованию"
});
networkRequest.AsyncRequestResult.SetCompleted();
continue;
}
// Проверяем устройство. Если оно в списке
if (faultyDevices.Contains(networkRequest.CurrentTransaction.Sender))
{
// Если устройство содежится в списке неисправных, то пропускаем его
networkRequest.CurrentTransaction.Start();
networkRequest.CurrentTransaction.Abort(new TransactionError
{
ErrorCode = TransactionErrorCodes.RequestTimeout,
Description =
"Исключено из обработки по причине неудачного предыдущего запроса к этому устройству"
});
networkRequest.AsyncRequestResult.SetCompleted();
continue;
}
// Выполняем сетевой запрос
ExecuteTransaction(networkRequest);
var result = networkRequest.AsyncRequestResult;
if (!result.IsCompleted)
{
throw new Exception("Сетевой запрос не выполнен. Это невозможно и никогда не должно появиться!!!");
}
if (result.HasError)
{
if (result.LastTransaction.Error.ErrorCode == TransactionErrorCodes.RequestTimeout)
{
// Запоминаем данное устройство, для того, что бы игнорировать
// все последующие запросы от данного устройства
if (!faultyDevices.Contains(result.Sender))
{
faultyDevices.Add(result.Sender);
//Установить ошибку в данном устройстве
result.Sender.CommunicationError = true;
}
}
}
else
{
// Проверяем: если запрос выполен успешно, но устройтсво содежит ошибку ComunicationError,
// то считаем, что связь с устройcтвом восстановилась и убираем данную ошибку
if (result.Sender.Errors.CommunicationError)
{
// удаляем данное устройтсво из списка неисправных
if (faultyDevices.Contains(result.Sender))
{
faultyDevices.Remove(result.Sender);
}
// сбросить ошибку в данном устройстве
result.Sender.CommunicationError = false;
}
}
}
}
}
示例7: SetSearchFilters
/// <summary>
/// Searches the filters.
/// </summary>
/// <param name="passengerPresenter">The passenger presenter.</param>
/// <param name="isExcept">if set to <c>true</c> [is except].</param>
/// <param name="searchType">Type of the search.</param>
/// <param name="pagingPageNumber">The paging page number.</param>
/// <param name="option">The option.</param>
/// <param name="isAll">The is all.</param>
/// <returns>
/// returns search filters
/// </returns>
private SearchFilters SetSearchFilters(PassengerPresenter passengerPresenter, bool isExcept, string searchType, int pagingPageNumber, string option, bool? isAll)
{
var exceptCountries = new List<string>();
List<string> selectedCountries = null;
var filteredCountries = string.Empty;
if (isExcept)
{
foreach (var country in passengerPresenter.Countries)
{
exceptCountries.Add(country.CountryId);
}
if (exceptCountries.Count > 0)
{
if (!string.IsNullOrEmpty(passengerPresenter.SelectedCitizenship))
{
var exceptSelectedCountries = passengerPresenter.SelectedCitizenship.Split(CommaSeparatorChar).Select(i => i.Trim()).Where(i => !string.IsNullOrEmpty(i)).ToList();
foreach (var selectedCountry in exceptSelectedCountries)
{
exceptCountries.Remove(selectedCountry);
}
filteredCountries = exceptCountries.JoinWith(CommaSeparator);
}
}
}
var searchFilter = new SearchFilters();
switch (searchType)
{
case Stateroom:
searchFilter.Stateroom = passengerPresenter.SearchText;
break;
case BookingNo:
searchFilter.ReservationNo = passengerPresenter.SearchText;
break;
case PassportNo:
searchFilter.PassportNo = passengerPresenter.SearchText;
break;
case LastName:
searchFilter.LastNameContains = passengerPresenter.SearchText;
break;
case Birthdate:
searchFilter.Birthdate = passengerPresenter.SearchText;
break;
default:
searchFilter.LastNameContains = passengerPresenter.SearchText;
break;
}
if (!string.IsNullOrEmpty(SessionData.Instance.IsMessageMode) && SessionData.Instance.IsMessageMode.Equals(TrueConstant, StringComparison.OrdinalIgnoreCase))
{
searchFilter.IsMessageCount = true;
searchFilter.IsMessage = true;
passengerPresenter.IsMessage = true;
searchFilter.IsAlertCount = false;
}
else
{
searchFilter.IsMessageCount = false;
searchFilter.IsMessage = false;
passengerPresenter.IsMessage = false;
searchFilter.IsAlertCount = true;
}
searchFilter.PersonTypeId = !string.IsNullOrEmpty(option) ? option : passengerPresenter.SelectedPassengerType;
searchFilter.VoyageId = passengerPresenter.SelectedVoyage;
if (!string.IsNullOrWhiteSpace(passengerPresenter.SelectedCitizenship))
{
selectedCountries = passengerPresenter.SelectedCitizenship.Split(',').ToList();
}
searchFilter.Citizenship = isExcept ? filteredCountries : selectedCountries != null && selectedCountries.Count == SessionData.Instance.MasterData.Countries.Count ? string.Empty : passengerPresenter.SelectedCitizenship;
searchFilter.MaxResult = ApplicationSettings.MaxPageSize;
searchFilter.PageNumber = pagingPageNumber > 0 ? pagingPageNumber : 1;
searchFilter.IsAll = isAll;
return searchFilter;
}
示例8: GetAvailableToHidePair
private static IndexPair GetAvailableToHidePair(GameFieldModel model, List<IndexPair> pairs, CancellationToken token, int rank)
{
foreach (var pair in pairs.ToList())
{
token.ThrowIfCancellationRequested();
model.SetItemVisible(pair, false);
if (GetHeuristicsAvailableNumbers(model, pair, rank).Count() <= 1)
return pair;
model.SetItemVisible(pair, true);
pairs.Remove(pair);
}
return null;
}
示例9: RemoveSink
/// <summary>
/// Remove a child logger.
/// </summary>
public bool RemoveSink(Logger sink)
{
lock (_syncRoot)
{
List<Logger> newSinks = new List<Logger>(_sinks);
if (newSinks.Remove(sink))
{
_sinks = newSinks.ToArray();
return true;
}
}
return false;
}
示例10: GetFreeSlot
public byte GetFreeSlot(int AcctId)
{
List<byte> FSlots = new List<byte>(8);
for (byte i = 1; i < 9; ++i)
FSlots.Add(i);
CharacterInfo[] Chars = GetInfos(AcctId);
if (Chars.Length >= 8)
return 0;
foreach (CharacterInfo Info in Chars)
FSlots.Remove(Info.Character.SlotId);
if (FSlots.Count <= 0)
return 0;
return FSlots[0];
}
示例11: Compute
public List<Node> Compute(int startX, int startY, int endX, int endY, Cell[][] matrix, bool improve)
{
List<Node> opened = new List<Node> ();
Priority_Queue.IPriorityQueue<Node> heap2 = new Priority_Queue.HeapPriorityQueue<Node> (600);
List<Node> closed = new List<Node> ();
// Initialize our version of the matrix (can we skip this?)
Node[][] newMatrix = new Node[matrix.Length][];
for (int x = 0; x < matrix.Length; x++) {
newMatrix [x] = new Node[matrix [x].Length];
for (int y = 0; y < matrix[x].Length; y++) {
newMatrix [x] [y] = new Node ();
newMatrix [x] [y].parent = null;
newMatrix [x] [y].cell = matrix [x] [y];
newMatrix [x] [y].x = x;
newMatrix [x] [y].y = y;
}
}
// Do the work for the first cell before firing the algorithm
start = newMatrix [startX] [startY];
end = newMatrix [endX] [endY];
closed.Add (start);
foreach (Node c in getAdjacent(start, newMatrix)) {
c.parent = start;
if (improve)
heap2.Enqueue (c, f (c));
else
opened.Add (c);
}
while ((improve && heap2.Count > 0) || (!improve && opened.Count > 0)) {
// Pick the closest to the goal
Node minF = null;
if (improve) {
minF = heap2.Dequeue ();
} else {
for (int i = 0; i < opened.Count; i++) {
if (minF == null || f (minF) > f (opened [i]))
minF = opened [i];
}
opened.Remove (minF);
}
closed.Add (minF);
// Found it
if (minF == end)
break;
foreach (Node adj in getAdjacent(minF, newMatrix)) {
float soFar = g (minF) + h (adj, minF);
// Create the links between cells (picks the best path)
if (closed.Contains (adj)) {
if (g (adj) > soFar) {
adj.parent = minF;
}
} else {
if ((improve && heap2.Contains (adj)) || (!improve && opened.Contains (adj))) {
if (g (adj) > soFar) {
adj.parent = minF;
}
} else {
adj.parent = minF;
if (improve)
heap2.Enqueue (adj, f (adj));
else
opened.Add (adj);
}
}
}
}
// Creates the result list
Node n = end;
List<Node> points = new List<Node> ();
while (n != null) {
points.Add (n);
n = n.parent;
}
points.Reverse ();
// If we didn't find a path
if (points.Count == 1)
points.Clear ();
return points;
}
示例12: getAdjacent
// Gets all the adjancent cells from the current one
private List<Node> getAdjacent(Node n, Node[][] matrix)
{
List<Node> adj = new List<Node> ();
for (int xx = n.x - 1; xx <= n.x +1; xx++) {
for (int yy = n.y - 1; yy <= n.y +1; yy++) {
if (xx <= n.x + 1 && xx >= 0 && xx < matrix.Length && yy <= n.y + 1 && yy >= 0 && yy < matrix [0].Length) {
Node c = matrix [xx] [yy];
if (!((Cell)c.cell).blocked) {
adj.Add (c);
}
}
}
}
adj.Remove (n);
return adj;
}
示例13: SetMembers
/// <summary>
/// メンバの打順とポジションを設定
/// </summary>
/// <param name="allPlayers">全選手一覧(スタメン選定時に同じ能力なら並び順が先を優先)</param>
private void SetMembers(List<Player> allPlayers)
{
// 各ポジションごとに強い順に新しいスタメンを設定
List<GameMember> newGameMembers = new List<GameMember>();
List<GameMember> newOutsideMembers = new List<GameMember>();
List<DefensePosition> pendingPositions = new List<DefensePosition>();
foreach (DefensePosition position in DefensePositionHelper.GetEnums)
{
Player player;
// 守備適正のあるメンバのうち、総合力が最も高いメンバを選定する
if (position == DefensePosition.Pitcher)
{
// コンバートにより投手でも存在しないことがありえるためFirstOrDefaultメソッドで取得
player = allPlayers.Where(m => DefenseTypeHelper.FitDefensePosition(position, m.FielderAbility.DefenseType)).OrderByDescending(m => m.PitcherAbility.Total).FirstOrDefault();
}
else
{
player = allPlayers.Where(m => DefenseTypeHelper.FitDefensePosition(position, m.FielderAbility.DefenseType)).OrderByDescending(m => m.FielderAbility.Total).FirstOrDefault();
}
if (player != null)
{
// 新しいメンバをスタメンに追加
GameMember member = new GameMember(player, position);
newGameMembers.Add(member);
// 選手一覧から追加メンバを削除
allPlayers.Remove(player);
}
else
{
// 適切な守備適性のメンバが存在せずnullの場合は再検討
pendingPositions.Add(position);
}
}
// 適切な守備適性でスタメンが埋まらない場合は、適当に総合力の高い順に選定
if (pendingPositions.Count > 0)
{
foreach (DefensePosition position in pendingPositions)
{
// 概ね適正のある守備位置から選定
Player player = allPlayers.Where(m => DefenseTypeHelper.MostFitDefensePosition(position, m.FielderAbility.DefenseType))
.OrderByDescending(m => m.FielderAbility.Total).FirstOrDefault();
// 概ねの適性もなければ投手以外で適当に選定
if (player == null)
{
player = allPlayers.OrderBy(m => m.IsPitcher).ThenByDescending(m => m.FielderAbility.Total).First();
}
// 新しいメンバをスタメンに追加
GameMember member = new GameMember(player, position);
newGameMembers.Add(member);
// 選手一覧から追加メンバを削除
allPlayers.Remove(player);
}
}
// この時点で9人となるはず
Assertion.Assert(newGameMembers.Count == 9, "newGameMembers.Count == 9");
// 打順は、以下の順にメンバの能力値で決める
// 9:投手(投手でも打撃強い場合があるが交代も考慮して9番とする)
// 4:[ミート+パワー×2]トップ(初期設定で友沢亮が4番になりにくくするため長打力を重視)
// 1:[ミート+走力]トップ
// 3:打者能力トップ
// 2:[ミート+智力]トップ
// 5:打者能力トップ
// 6:打者能力トップ
// 7:打者能力トップ
// 8:打者能力トップ
GameMember member9 = newGameMembers.OrderByDescending(m => m.DefensePosition == DefensePosition.Pitcher).First();
newGameMembers.Remove(member9);
GameMember member4 = newGameMembers.OrderByDescending(m => m.Meet + m.Power * 2).First();
newGameMembers.Remove(member4);
GameMember member1 = newGameMembers.OrderByDescending(m => m.Meet + m.Run).First();
newGameMembers.Remove(member1);
GameMember member3 = newGameMembers.OrderByDescending(m => m.BatterAbility).First();
newGameMembers.Remove(member3);
GameMember member2 = newGameMembers.OrderByDescending(m => m.Meet + m.Wisdom).First();
newGameMembers.Remove(member2);
GameMember member5 = newGameMembers.OrderByDescending(m => m.BatterAbility).First();
newGameMembers.Remove(member5);
GameMember member6 = newGameMembers.OrderByDescending(m => m.BatterAbility).First();
newGameMembers.Remove(member6);
GameMember member7 = newGameMembers.OrderByDescending(m => m.BatterAbility).First();
newGameMembers.Remove(member7);
GameMember member8 = newGameMembers.OrderByDescending(m => m.BatterAbility).First();
newGameMembers.Remove(member8);
// 一番から打順の順番で追加し直す
newGameMembers.Add(member1);
newGameMembers.Add(member2);
newGameMembers.Add(member3);
//.........这里部分代码省略.........
示例14: GetMissingChunks
public List<int> GetMissingChunks(string TicketId, string Path, int ChunkSize = 1048576)
{
var fi = new FileInfo(Path);
var count = GetChunksCount(fi.Length, ChunkSize);
var c = vimeo_videos_upload_verifyChunks(TicketId);
List<int> chunks = new List<int>();
if (ChunkSize < 0)
{
if (c == null || c.Items.Count == 0) return chunks;
chunks.Add(0);
return chunks;
}
for (int i = 0; i < count; i++)
{
chunks.Add(i);
}
if (c == null)
{
return chunks;
}
foreach (var item in c.Items)
{
if (item.size == GetChunkSize(fi.Length, item.id, ChunkSize))
chunks.Remove(item.id);
}
return chunks;
}
示例15: ResumeUploadInChunks
string ResumeUploadInChunks(string path, Ticket t, int chunk_size, int max_chunks, bool firstTime)
{
const int maxFailedAttempts = 5;
if (!firstTime)
{
// Check the ticket
Debug.WriteLine("ResumeUploadInChunks(" + path + ") Checking ticket...", "VimeoClient");
var ticket = vimeo_videos_upload_checkTicket(t.id);
if (ticket == null || ticket.id != t.id)
{
Debug.WriteLine("Error in checking ticket. aborting.", "VimeoClient");
return null;
}
t = ticket;
}
//Load the file, calculate the number of chunks
var file = new FileInfo(path);
int chunksCount = GetChunksCount(file.Length, chunk_size);
Debug.WriteLine("Will upload in " + chunksCount + " chunks", "VimeoClient");
//Queue chunks for upload
List<int> missingChunks = new List<int>(chunksCount);
for (int i = 0; i < chunksCount; i++) missingChunks.Add(i);
int failedAttempts = 0;
int counter = 0;
while (failedAttempts <= maxFailedAttempts)
{
if (firstTime)
{
firstTime = false;
}
else
{
//Verify and remove the successfully uploaded chunks
Debug.WriteLine("Verifying chunks...", "VimeoClient");
var verify = vimeo_videos_upload_verifyChunks(t.id);
Debug.WriteLine(verify.Items.Count.ToString() + "/" + chunksCount + " chunks uploaded successfully.", "VimeoClient");
missingChunks.Clear();
for (int i = 0; i < chunksCount; i++) missingChunks.Add(i);
foreach (var item in verify.Items)
{
if (missingChunks.Contains(item.id) && item.size == GetChunkSize(file.Length, item.id, chunk_size))
missingChunks.Remove(item.id);
}
}
//If there are no chunks left or the limit is reached stop.
if (missingChunks.Count == 0 || (max_chunks > 0 && counter >= max_chunks))
break;
//Post chunks
while (missingChunks.Count > 0)
{
//If there are no chunks left or the limit is reached stop.
if (missingChunks.Count == 0 || (max_chunks > 0 && counter >= max_chunks))
break;
if (failedAttempts > maxFailedAttempts) break;
int chunkId = missingChunks[0];
missingChunks.RemoveAt(0);
Debug.WriteLine("Posting chunk " + chunkId + ". " + missingChunks.Count + " chunks left.", "VimeoClient");
try
{
counter++;
PostVideo(t, chunkId, path, chunk_size);
}
catch (Exception e)
{
Debug.WriteLine(e, "VimeoClient");
failedAttempts++;
}
}
}
if (missingChunks.Count == 0)
{
//All chunks are uploaded
return vimeo_videos_upload_complete(file.Name, t.id);
}
if ((max_chunks > 0 && counter >= max_chunks))
{
//Max limit is reached
return string.Empty;
}
//Error
return null;
}