本文整理汇总了C#中Mapper.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# Mapper.RemoveAt方法的具体用法?C# Mapper.RemoveAt怎么用?C# Mapper.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapper
的用法示例。
在下文中一共展示了Mapper.RemoveAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetToNull
public void SetToNull()
{
var mapper = new Mapper<string>();
string result;
bool isNew;
Assert.IsTrue(mapper.Insert(0, null));
Assert.IsTrue(mapper.TryGet(0, out result));
Assert.AreEqual(null, result);
Assert.IsTrue(mapper.RemoveAt(0, out result));
Assert.AreEqual(null, result);
Assert.IsTrue(mapper.Exchange(0, null, out result));
Assert.AreEqual(null, result);
Assert.IsFalse(mapper.Insert(0, null, out result));
Assert.AreEqual(null, result);
mapper.Set(0, "Hello", out isNew);
Assert.IsFalse(isNew);
Assert.IsTrue(mapper.TryGet(0, out result));
Assert.AreEqual("Hello", result);
mapper.Set(0, null, out isNew);
Assert.IsFalse(isNew);
Assert.IsTrue(mapper.TryGet(0, out result));
Assert.AreEqual(null, result);
mapper.Exchange(0, "Hello", out result);
Assert.AreEqual(null, result);
mapper.Exchange(0, null, out result);
Assert.AreEqual("Hello", result);
Assert.AreEqual(1, mapper.Count);
}
示例2: TwoThreadsRemoveAt
public void TwoThreadsRemoveAt()
{
var mapper = new Mapper<int>();
const int Input = 21;
var info = new CircularBucket<string>(16);
var startEvent = new ManualResetEvent(false);
int[] done = {0};
var threads = new[]
{
new Thread
(
() =>
{
int result;
bool isNew;
mapper.Set(0, Input, out isNew);
info.Add("A: Set - was new: " + isNew);
bool removed = mapper.RemoveAt(0, out result);
info.Add(removed ? "A: Removed" : "A: Could not remove");
Interlocked.Increment(ref done[0]);
}
),
new Thread
(
() =>
{
int result;
bool isNew;
mapper.Set(0, Input, out isNew);
info.Add("B: Set - was new: " + isNew);
bool removed = mapper.RemoveAt(0, out result);
info.Add(removed ? "B: Removed" : "B: Could not remove");
Interlocked.Increment(ref done[0]);
}
)
};
threads[0].Start();
threads[1].Start();
startEvent.Set();
while (true)
{
if (Thread.VolatileRead(ref done[0]) == 2)
{
break;
}
Thread.Sleep(0);
}
Assert.AreEqual(0, mapper.Count);
}
示例3: RemoveAt
public void RemoveAt()
{
var mapper = new Mapper<int>();
const int Input = 21;
int result;
bool isNew;
//---
mapper.Set(0, Input, out isNew);
Assert.IsTrue(isNew);
Assert.IsTrue(mapper.TryGet(0, out result));
Assert.AreEqual(Input, result);
Assert.IsTrue(mapper.RemoveAt(0, out result));
Assert.AreEqual(Input, result);
Assert.IsFalse(mapper.TryGet(0, out result));
Assert.IsFalse(mapper.RemoveAt(1, out result));
Assert.IsFalse(mapper.TryGet(1, out result));
//---
mapper.Set(0, Input, out isNew);
Assert.IsTrue(isNew);
Assert.IsTrue(mapper.TryGet(0, out result));
Assert.AreEqual(Input, result);
Assert.IsTrue(mapper.RemoveAt(0));
Assert.IsFalse(mapper.TryGet(0, out result));
Assert.IsFalse(mapper.RemoveAt(1));
Assert.IsFalse(mapper.TryGet(1, out result));
Assert.AreEqual(0, mapper.Count);
}