本文整理汇总了C#中ImmutableList.RemoveAtFromNew方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableList.RemoveAtFromNew方法的具体用法?C# ImmutableList.RemoveAtFromNew怎么用?C# ImmutableList.RemoveAtFromNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableList
的用法示例。
在下文中一共展示了ImmutableList.RemoveAtFromNew方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateRemoteTAs
/**
* Updates the RemoteTA list hosted by the Node.
*/
virtual public void UpdateRemoteTAs(IList<TransportAddress> tas_to_add)
{
IList<TransportAddress> local_tas = LocalTAs;
lock(_sync) {
// Remove duplicates in tas_to_add
var dup_test = new Dictionary<TransportAddress, bool>();
foreach(TransportAddress ta in tas_to_add) {
if(dup_test.ContainsKey(ta) || local_tas.Contains(ta)) {
continue;
}
dup_test.Add(ta, true);
}
// Remove duplicates found in tas_to_add and _remote_ta. If we don't,
// we could be flooded by a single node and lose track of good TAs.
foreach(TransportAddress ta in _remote_ta) {
if(dup_test.ContainsKey(ta)) {
dup_test.Remove(ta);
}
}
// Add in the remaining TAs
foreach(TransportAddress ta in dup_test.Keys) {
_remote_ta = _remote_ta.PushIntoNew(ta);
}
// Remove older TAs after _MAX_RECORDED_TAS
int count = _remote_ta.Count;
if(count > _MAX_RECORDED_TAS) {
for(int i = _MAX_RECORDED_TAS; i < count; i++) {
_remote_ta = _remote_ta.RemoveAtFromNew(_MAX_RECORDED_TAS);
}
}
}
}