本文整理匯總了C#中NUnit.Framework.List.RemoveAt方法的典型用法代碼示例。如果您正苦於以下問題:C# List.RemoveAt方法的具體用法?C# List.RemoveAt怎麽用?C# List.RemoveAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NUnit.Framework.List
的用法示例。
在下文中一共展示了List.RemoveAt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: sendData
/**
* correlates the data based on timestamps
* handling just 2 lists right now.
* TODO: eventually we would want to handle all the lists in the directory
*/
public List<TransponderData> sendData (List<TransponderData> dataList )
{
var listToSend = new List<TransponderData> ();
listToSend.Add (dataList [0]);
for (int i = 1; i<dataList.Count; i++)
{
if((dataList [0].Timestamp).Equals (dataList [i].Timestamp))
{
listToSend.Add (dataList[i]);
dataList.RemoveAt(i);
}
else
{
break;
}
}
dataList.RemoveAt(0);
BroadcastDataEvent (listToSend);
System.Threading.Thread.Sleep (200);
return dataList;
}
示例2: TestRandomAllocation
public void TestRandomAllocation()
{
int repeatCount = 10000;
int range = 100;
IList<int> allocated = new List<int>();
IntAllocator intAllocator = new IntAllocator(0, range);
Random rand = new Random();
while (repeatCount-- > 0)
{
if (rand.Next(2) == 0)
{
int a = intAllocator.Allocate();
if (a > -1)
{
Assert.False(allocated.Contains(a));
allocated.Add(a);
}
}
else if (allocated.Count > 0)
{
int a = allocated[0];
intAllocator.Free(a);
allocated.RemoveAt(0);
}
}
}
示例3: UniqueTreeTest
public void UniqueTreeTest ()
{
// Unique tree
var expectedRemain = new List<double>();
var tree = new Tree<double, string>(
new TreeMemoryNodeManager<double, string>(2, Comparer<double>.Default)
);
// Insert random numbers
for (var i = 0; i < 1000; i++) {
tree.Insert (i, i.ToString());
expectedRemain.Add (i);
}
// Start deleting randomly
var rnd = new Random ();
for (var i = 0; i < 1000; i++) {
var deleteAt = rnd.Next (0, expectedRemain.Count);
var keyToDelete = expectedRemain[deleteAt];
expectedRemain.RemoveAt (deleteAt);
tree.Delete (keyToDelete);
var remain = (from entry in tree.LargerThanOrEqualTo(0) select entry.Item1).ToArray();
Assert.IsTrue (remain.SequenceEqual (expectedRemain));
}
Assert.Throws<InvalidOperationException>(delegate {
tree.Delete (888, "888");
});
}
示例4: ListBasics
public void ListBasics()
{
var names = new List<string>();
names.Add("fred");
Assert.AreEqual("fred", names[0]);
Assert.AreEqual(1, names.Count);
names.Add("betty");
Assert.AreEqual(2, names.Count);
names.RemoveAt(0); // After we remove Fred, we have Bett
Assert.AreEqual(1, names.Count);
Assert.AreEqual("betty", names[0]);
names[0] = "barney";
//foreach (string name in names)
//{
// Console.WriteLine(name);
//}
//var integers = new List<int>(50) {10, 20};
//Equivalent to:
var tmp = new List<int>(50);
tmp.Add(10);
tmp.Add(20);
var integers = tmp;
integers = new List<int>() { integers.Count };
Assert.AreEqual(2, integers[0]);
}
示例5: FindTop10VideoFriends_CountOfListVideoLess10
public void FindTop10VideoFriends_CountOfListVideoLess10()
{
List<Video> listVideo = new List<Video>();
listVideo = FillingListVideo(listVideo);
listVideo.RemoveAt(9);
Assert.AreEqual(listVideo, control.FindTop10Video(listVideo));
}
示例6: GetSiblings
public void GetSiblings()
{
var a = new List<IPAddress> {
new IPAddress(Ba(192, 168, 178, 0)),
new IPAddress(Ba(192, 168, 178, 1)),
new IPAddress(Ba(192, 168, 178, 2)),
new IPAddress(Ba(192, 168, 178, 3)),
new IPAddress(Ba(192, 168, 178, 4)),
new IPAddress(Ba(192, 168, 178, 5)),
new IPAddress(Ba(192, 168, 178, 6)),
new IPAddress(Ba(192, 168, 178, 7))
};
var ip = new IPAddress(Ba(192, 168, 178, 5));
var mask = new NetMask(255, 255, 255, 248);
TestSiblings(a, ip, mask);
a = new List<IPAddress> {
new IPAddress(Ba(10, 20, 3, 192)),
// new IPAddress(Ba(10, 20, 3, 193)),
new IPAddress(Ba(10, 20, 3, 194)),
new IPAddress(Ba(10, 20, 3, 195)),
new IPAddress(Ba(10, 20, 3, 196)),
new IPAddress(Ba(10, 20, 3, 197)),
new IPAddress(Ba(10, 20, 3, 198)),
new IPAddress(Ba(10, 20, 3, 199)),
new IPAddress(Ba(10, 20, 3, 200)),
new IPAddress(Ba(10, 20, 3, 201)),
new IPAddress(Ba(10, 20, 3, 202)),
new IPAddress(Ba(10, 20, 3, 203)),
new IPAddress(Ba(10, 20, 3, 204)),
new IPAddress(Ba(10, 20, 3, 205)),
new IPAddress(Ba(10, 20, 3, 206)),
new IPAddress(Ba(10, 20, 3, 207))
};
ip = new IPAddress(Ba(10, 20, 3, 193));
mask = new NetMask(255, 255, 255, 240);
TestSiblings(a, ip, mask, SiblingOptions.IncludeNetworkIdentifier | SiblingOptions.IncludeBroadcast);
a.RemoveAt(a.Count - 1);
TestSiblings(a, ip, mask, SiblingOptions.IncludeNetworkIdentifier);
a.RemoveAt(0);
TestSiblings(a, ip, mask, SiblingOptions.ExcludeAll);
}
示例7: HasSameContentsAs
public void HasSameContentsAs()
{
var listA = new List<string> { "a", "z", "alpha" };
var listB = new List<string> { "alpha", "a", "z", };
Assert.IsTrue(listA.HasSameContentsAs(listB), "same content, diff order");
listA.RemoveAt(0);
Assert.IsFalse(listA.HasSameContentsAs(listB), "not the same content");
listA.Add("b");
Assert.IsFalse(listA.HasSameContentsAs(listB), "not the same content");
}
示例8: TestMultipleWriterReader
public virtual void TestMultipleWriterReader()
{
Counter bytesUsed = Util.Counter.NewCounter();
IntBlockPool pool = new IntBlockPool(new ByteTrackingAllocator(bytesUsed));
for (int j = 0; j < 2; j++)
{
IList<StartEndAndValues> holders = new List<StartEndAndValues>();
int num = AtLeast(4);
for (int i = 0; i < num; i++)
{
holders.Add(new StartEndAndValues(Random().Next(1000)));
}
IntBlockPool.SliceWriter writer = new IntBlockPool.SliceWriter(pool);
IntBlockPool.SliceReader reader = new IntBlockPool.SliceReader(pool);
int numValuesToWrite = AtLeast(10000);
for (int i = 0; i < numValuesToWrite; i++)
{
StartEndAndValues values = holders[Random().Next(holders.Count)];
if (values.ValueCount == 0)
{
values.Start = writer.StartNewSlice();
}
else
{
writer.Reset(values.End);
}
writer.WriteInt(values.NextValue());
values.End = writer.CurrentOffset;
if (Random().Next(5) == 0)
{
// pick one and reader the ints
AssertReader(reader, holders[Random().Next(holders.Count)]);
}
}
while (holders.Count > 0)
{
int randIndex = Random().Next(holders.Count);
StartEndAndValues values = holders[randIndex];
holders.RemoveAt(randIndex);
AssertReader(reader, values);
}
if (Random().NextBoolean())
{
pool.Reset(true, false);
Assert.AreEqual(0, bytesUsed.Get());
}
else
{
pool.Reset(true, true);
Assert.AreEqual(IntBlockPool.INT_BLOCK_SIZE * RamUsageEstimator.NUM_BYTES_INT, bytesUsed.Get());
}
}
}
示例9: TestModifyMaster
public void TestModifyMaster()
{
List<string> strings = new List<string>(new string[] { "a", "b", "c" });
ReadOnlyList<String> read = new ReadOnlyList<string>(strings, false);
Assert.AreEqual(3, read.Count);
strings.RemoveAt(2);
Assert.AreEqual(2, read.Count);
Assert.AreEqual("a", read[0]);
Assert.AreEqual("b", read[1]);
Assert.AreEqual("a,b", String.Join(",", read.Clone().ToArray()));
}
示例10: List_Has_Dynamic_Size
public void List_Has_Dynamic_Size()
{
var names = new List<string>();
names.Add("fred");
Assert.That(names.Count, Is.EqualTo(1));
names.Add("betty");
Assert.That(names.Count, Is.EqualTo(2));
names.RemoveAt(0);
Assert.That(names.Count, Is.EqualTo(1));
}
示例11: TestExecute
public void TestExecute()
{
var list = new List<int> ();
Action<int,int> exeAction = (i, v) => list.Insert (i, v);
Action<int,int> undoAction = (i, v) => list.RemoveAt (i);
var command = new Command<int,int>(0,4,exeAction, undoAction);
command.Execute ();
Assert.AreEqual (1, list.Count);
Assert.AreEqual (list[0],4);
command.Undo ();
Assert.AreEqual (0, list.Count);
}
示例12: Test
public void Test()
{
var rand = new Random(3);
List<string> list1 = new List<string>();
WeakList<string> list2 = new WeakList<string>();
for (int x = 0; x < 1000; x++)
{
var str = x.ToString();
list1.Add(str);
list2.Add(str);
if (!list1.SequenceEqual(list2))
throw new Exception("Lists are not the same.");
}
for (int x = 1000; x < 2000; x++)
{
var str = x.ToString();
var removeItem = list1[rand.Next(list1.Count)];
list1.Remove(removeItem);
list2.Remove(removeItem);
if (!list1.SequenceEqual(list2))
throw new Exception("Lists are not the same.");
list1.Add(str);
list2.Add(str);
if (!list1.SequenceEqual(list2))
throw new Exception("Lists are not the same.");
}
for (int x = 0; x < 100; x++)
{
list1.RemoveAt(rand.Next(list1.Count));
GC.Collect();
if (!list1.SequenceEqual(list2))
throw new Exception("Lists are not the same.");
}
list2.Clear();
foreach (var data in list2)
throw new Exception();
}
示例13: Matches_ActualMoreThanExpectation_Failure
public void Matches_ActualMoreThanExpectation_Failure()
{
var discovery = new DiscoveryRequestFactory().BuildDirect(
ConnectionStringReader.GetAdomd()
, DiscoveryTarget.Perspectives
, new List<IFilter>());
var expectedStrings = new string[] { "Adventure Works", "Channel Sales", "Direct Sales", "Finance", "Sales Summary", "Sales Targets" };
var expected = new List<string>();
expected.AddRange(expectedStrings);
expected.RemoveAt(0);
var ctr = new EquivalentToConstraint(expected);
//Method under test
Assert.That(ctr.Matches(discovery), Is.False);
}
示例14: MergeKLists
public ListNode MergeKLists(ListNode[] lists)
{
if (lists == null || lists.Length == 0) return null;
if (lists.Length == 1) return lists[0];
ListNode head = null;
ListNode current = null;
var toManipulate = new List<ListNode>(lists.Where(l => l != null));
while (toManipulate.Count > 0)
{
int lowestValue = int.MaxValue;
int lowestIdx = 0;
for (var idx = 0; idx < toManipulate.Count; ++idx)
{
if (toManipulate[idx].val < lowestValue)
{
lowestValue = toManipulate[idx].val;
lowestIdx = idx;
}
}
if (head == null)
{
head = toManipulate[lowestIdx];
current = head;
}
else
{
current.next = toManipulate[lowestIdx];
current = current.next;
}
var next = toManipulate[lowestIdx].next;
if (next == null)
{
toManipulate.RemoveAt(lowestIdx);
}
else
{
toManipulate[lowestIdx] = next;
}
}
return head;
}
示例15: AllNodesAreCoveredDuringIteration
public void AllNodesAreCoveredDuringIteration()
{
var nodeArray = new List<Node>();
for (var i = 0; i < 5; ++i)
{
var node = new MockNode();
nodeArray.Add(node);
_nodes.Add(node);
}
for (var node = _nodes.Head; node != null; node = node.Next)
{
var index = nodeArray.IndexOf(node);
nodeArray.RemoveAt(index);
}
Assert.AreEqual(0, nodeArray.Count);
}