本文整理汇总了C#中VList.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# VList.Insert方法的具体用法?C# VList.Insert怎么用?C# VList.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VList
的用法示例。
在下文中一共展示了VList.Insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AltType
public AltType(VList<LNode> classAttrs, LNode typeName, VList<LNode> baseTypes, AltType parentType)
{
_classAttrs = classAttrs;
TypeName = typeName;
BaseTypes = baseTypes;
ParentType = parentType;
//matchCode (TypeName) {
// case $stem<$(..a)>, $stem:
// _typeNameStem = stem;
// _genericArgs = a;
// default:
// _genericArgs = new WList<LNode>();
//}
{ // Above matchCode expanded:
LNode stem;
VList<LNode> a = default(VList<LNode>);
if (TypeName.CallsMin(CodeSymbols.Of, 1) && (stem = TypeName.Args[0]) != null && (a = new VList<LNode>(TypeName.Args.Slice(1))).IsEmpty | true || (stem = TypeName) != null) {
_typeNameStem = stem;
_genericArgs = a.ToWList();
} else {
_genericArgs = new WList<LNode>();
}
}
if (ParentType != null) {
BaseTypes.Insert(0, ParentType.TypeNameWithoutAttrs);
// Search for all 'where' clauses on the ParentType and make sure OUR generic args have them too.
bool changed = false;
for (int i = 0; i < _genericArgs.Count; i++) {
var arg = _genericArgs[i];
var parentArg = ParentType._genericArgs.FirstOrDefault(a => a.IsIdNamed(arg.Name));
if (parentArg != null) {
var wheres = new HashSet<LNode>(WhereTypes(arg));
int oldCount = wheres.Count;
var parentWheres = WhereTypes(parentArg);
foreach (var where in parentWheres)
wheres.Add(where);
if (wheres.Count > oldCount) {
arg = arg.WithAttrs(arg.Attrs.SmartWhere(a => !a.Calls(S.Where))
.Add(LNode.Call(S.Where, LNode.List(wheres))));
_genericArgs[i] = arg;
changed = true;
}
}
}
if (changed)
TypeName = LNode.Call(CodeSymbols.Of, LNode.List().Add(_typeNameStem).AddRange(_genericArgs)).SetStyle(NodeStyle.Operator);
}
TypeNameWithoutAttrs = TypeName.Select(n => n.WithoutAttrs());
}
示例2: AltType
public AltType(VList<LNode> classAttrs, LNode typeName, VList<LNode> baseTypes, AltType parentType)
{
_classAttrs = classAttrs;
TypeName = typeName;
BaseTypes = baseTypes;
ParentType = parentType;
{
LNode stem;
VList<LNode> a = default(VList<LNode>);
if (TypeName.CallsMin(CodeSymbols.Of, 1) && (stem = TypeName.Args[0]) != null && (a = new VList<LNode>(TypeName.Args.Slice(1))).IsEmpty | true || (stem = TypeName) != null) {
_typeNameStem = stem;
_genericArgs = a.ToWList();
} else {
_genericArgs = new WList<LNode>();
}
}
if (ParentType != null) {
BaseTypes.Insert(0, ParentType.TypeNameWithoutAttrs);
bool changed = false;
for (int i = 0; i < _genericArgs.Count; i++) {
var arg = _genericArgs[i];
var parentArg = ParentType._genericArgs.FirstOrDefault(a => a.IsIdNamed(arg.Name));
if (parentArg != null) {
var wheres = new HashSet<LNode>(WhereTypes(arg));
int oldCount = wheres.Count;
var parentWheres = WhereTypes(parentArg);
foreach (var where in parentWheres)
wheres.Add(where);
if (wheres.Count > oldCount) {
arg = arg.WithAttrs(arg.Attrs.Where(a => !a.Calls(S.Where)).Add(LNode.Call(S.Where, LNode.List(wheres))));
_genericArgs[i] = arg;
changed = true;
}
}
}
if (changed)
TypeName = LNode.Call(CodeSymbols.Of, LNode.List().Add(_typeNameStem).AddRange(_genericArgs));
}
TypeNameWithoutAttrs = TypeName.Select(n => n.WithoutAttrs());
}
示例3: TestEmptyListOperations
public void TestEmptyListOperations()
{
VList<int> a = new VList<int>();
VList<int> b = new VList<int>();
a.AddRange(b);
a.InsertRange(0, b);
a.RemoveRange(0, 0);
Assert.That(!a.Remove(0));
Assert.That(a.IsEmpty);
a.Add(1);
b.AddRange(a);
ExpectList(b, 1);
b.RemoveAt(0);
Assert.That(b.IsEmpty);
b.InsertRange(0, a);
ExpectList(b, 1);
b.RemoveRange(0, 1);
Assert.That(b.IsEmpty);
b.Insert(0, a[0]);
ExpectList(b, 1);
b.Remove(a.Last);
Assert.That(b.IsEmpty);
AssertThrows<InvalidOperationException>(delegate() { a.NextIn(b); });
}
示例4: TestInsertRemove
public void TestInsertRemove()
{
VList<int> list = new VList<int>(9);
VList<int> list2 = new VList<int>(10, 11);
list.Insert(0, 12);
list.Insert(1, list2[1]);
list.Insert(2, list2[0]);
ExpectList(list, 12, 11, 10, 9);
for (int i = 0; i < 9; i++)
list.Insert(4, i);
ExpectList(list, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
list2 = list;
for (int i = 1; i <= 6; i++)
list2.RemoveAt(i);
ExpectList(list2, 12, 10, 8, 6, 4, 2, 0);
ExpectList(list, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); // unchanged
Assert.AreEqual(0, list2.Pop());
list2.Insert(5, -2);
ExpectList(list2, 12, 10, 8, 6, 4, -2, 2);
list2.Insert(5, -1);
ExpectList(list2, 12, 10, 8, 6, 4, -1, -2, 2);
// Test changing items
list = list2;
for (int i = 0; i < list.Count; i++)
list[i] = i;
ExpectList(list, 0, 1, 2, 3, 4, 5, 6, 7);
ExpectList(list2, 12, 10, 8, 6, 4, -1, -2, 2);
list2.Clear();
ExpectList(list2);
Assert.AreEqual(5, list[5]);
}