本文整理汇总了C#中List.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# List.RemoveAt方法的具体用法?C# List.RemoveAt怎么用?C# List.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List.RemoveAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Encode
protected string Encode(string value)
{
UTF8Encoding encoding = new UTF8Encoding();
switch (_DataType.Encoding)
{
case "BASE64": return Convert.ToBase64String(encoding.GetBytes(value));
case "7BIT":
case "8BIT":
value = Regex.Replace(value, @"[^\r]\n", "\r\n");
value = Regex.Replace(value, @"\r[^\n]", "\r\n");
bool is7Bit = _DataType.Encoding.Equals("7BIT");
List<byte> data = new List<byte>(encoding.GetBytes(value));
for (int i = data.Count - 1; i >= 0; i--)
{
if (data[i] == 0)
data.RemoveAt(i);
if (is7Bit && data[i] > 127)
data.RemoveAt(i);
}
return encoding.GetString(data.ToArray());
default:
return value;
}
}
示例2: CreateTemplate
public Template CreateTemplate()
{
List<Cylinder> listCylinders = new List<Cylinder>();
foreach (var middleMinutia in _minutiaeList)
{
int count = GetCountMinutia(middleMinutia);
if (count >= MinNumberMinutiae)
{
Cylinder[] cylinders = CreateCylinders(middleMinutia);
listCylinders.Add(cylinders[0]);
listCylinders.Add(cylinders[1]);
}
}
uint maxCount = GetMaxCount(listCylinders);
for (int i = 1; i < listCylinders.Count; i += 2)
{
if (CylinderHelper.GetOneBitsCount(listCylinders[i].Values) >= 0.75 * maxCount)
{
continue;
}
listCylinders.RemoveAt(i--);
listCylinders.RemoveAt(i--);
}
return new Template(listCylinders.ToArray());
}
示例3: replaceTokensWithResult
private void replaceTokensWithResult(List<MathToken> tokens,
int indexOfOperator, int result)
{
tokens[indexOfOperator - 1] = new MathNumber(result.ToString());
tokens.RemoveAt(indexOfOperator);
tokens.RemoveAt(indexOfOperator);
}
示例4: Execute
public void Execute(List<string> arguments)
{
if (arguments.Count == 0)
{
ShowNoArgsMessage();
}
else
{
while (arguments.Count != 0)
{
string key;
string value;
key = arguments[0];
arguments.RemoveAt(0);
if (arguments.ElementAtOrDefault(0) != null)
{
value = arguments[0];
arguments.RemoveAt(0);
}
else
{
value = "<null>";
}
Console.WriteLine("{0} - {1}", key, value);
}
}
}
示例5: merge
public static List<int> merge(List<int> left, List<int> right)
{
List<int> result = new List<int>();
while (left.Count > 0 && right.Count > 0)
{
if (left[0] < right[0])
{
result.Add(left[0]);
left.RemoveAt(0);
}
else
{
result.Add(right[0]);
right.RemoveAt(0);
}
}
while (left.Count > 0)
{
result.Add(left[0]);
left.RemoveAt(0);
}
while (right.Count > 0)
{
result.Add(right[0]);
right.RemoveAt(0);
}
return result;
}
示例6: CoverageDistributePoint
public static List<GeoXYPoint> CoverageDistributePoint(GeoPolygon polygonPeak, double r)
{
List<GeoXYPoint> list = new List<GeoXYPoint>();
GeoXYPoint centerPoint = new GeoXYPoint((polygonPeak.Right + polygonPeak.Left) / 2.0, (polygonPeak.Top + polygonPeak.Bottom) / 2.0);
GeoXYPoint southwest = GetSouthWestPoint(polygonPeak.Left, polygonPeak.Right, polygonPeak.Top, polygonPeak.Bottom, centerPoint, r);
GeoXYPoint northeast = GetNorthEastClutterPoint(polygonPeak.Left, polygonPeak.Right, polygonPeak.Top, polygonPeak.Bottom, centerPoint, r);
list = InitialDistribute(southwest, northeast, r);
int index = 0;
while (index < list.Count)
{
if (!polygonPeak.IsPointInPolygon(list[index]))
{
list.RemoveAt(index);
index--;
}
index++;
}
for (int i = 0; list.Count == 0; i++)
{
if (i >= polygonPeak.Points.Count)
{
return list;
}
list = InitialDistribute(polygonPeak.Points[i], northeast, r);
for (index = 0; index < list.Count; index++)
{
if (!polygonPeak.IsPointInPolygon(list[index]))
{
list.RemoveAt(index);
index--;
}
}
}
return list;
}
示例7: Merge
private static List<int> Merge(List<int> leftList, List<int> rightList)
{
List<int> result = new List<int>();
while (leftList.Count > 0 || rightList.Count > 0)
{
if (leftList.Count > 0 && rightList.Count > 0)
{
if (leftList[0] <= rightList[0])
{
result.Add(leftList[0]);
leftList.RemoveAt(0);
}
else
{
result.Add(rightList[0]);
rightList.RemoveAt(0);
}
}
else if (leftList.Count > 0)
{
result.Add(leftList[0]);
leftList.RemoveAt(0);
}
else if (rightList.Count > 0)
{
result.Add(rightList[0]);
rightList.RemoveAt(0);
}
}
return result;
}
示例8: Main
static void Main(string[] args)
{
string[] sequence = Console.ReadLine().Split();
int kN = int.Parse(Console.ReadLine());
int count = 1;
List<int> seq = new List<int>();
foreach (var item in sequence)
{
seq.Add(int.Parse(item));
}
int num = seq[0];
for (int i = 1; i < seq.Count; i++)
{
if (num==seq[i])
{
count++;
if (count==kN)
{
seq.RemoveAt(i);
seq.RemoveAt(i - 1);
count = 1;
}
}
}
}
示例9: Write
public static void Write(BinaryWriter writer, DateTime? time)
{
if (!time.HasValue)
{
// 1 byte long
byte[] nullBytes = { 255 };
writer.Write(nullBytes);
return;
}
// byte is 1 byte long :)
const byte size = 5;
writer.Write(size);
// Format:
// 00:00:00 gives 05 00 00 00 00 00
// 00:00:01 gives 05 80 96 98 00 00 -> 00 00 98 96 80 = 1.0000000
// 00:01:00 gives 05 00 46 C3 23 00 -> 00 23 C3 46 00 = 60.0000000
// 01:00:00 gives 05 00 68 C4 61 08 -> 08 61 C4 68 00 = 3600.0000000
DateTime initTime = DateTime.Parse("00:00:00", System.Globalization.CultureInfo.InvariantCulture);
TimeSpan span = time.Value - initTime;
byte[] valueBytes = BitConverter.GetBytes((long)(span.TotalSeconds * 10000000));
List<byte> bytes = new List<byte>(valueBytes);
bytes.RemoveAt(7);
bytes.RemoveAt(6);
bytes.RemoveAt(5);
writer.Write(bytes.ToArray());
}
示例10: FindArticle
protected string FindArticle(List<string> w, List<string> t)
{
for (int i = 0; i < t.Count; ++i)
{
if ((t[i] == Tagger.Tags.Noun) || (t[i] == Tagger.Tags.NounPlural))
{
if ((i > 0) && (t[i - 1] == Tagger.Tags.Determiner))
{
t.RemoveAt(i - 1);
w.RemoveAt(i - 1);
--i;
}
string s = w[i];
t.RemoveAt(i);
w.RemoveAt(i);
while ((i < t.Count) && ((t[i] == Tagger.Tags.Noun) || (t[i] == Tagger.Tags.NounPlural)))
{
s += " " + w[i];
t.RemoveAt(i);
w.RemoveAt(i);
}
return s;
}
}
return string.Empty;
}
示例11: Cd
public Path Cd(string newPath)
{
if (newPath.Length > 2 && newPath.Substring(0, 2) == "./")
{
newPath = newPath.Substring(2, newPath.Length - 2);
}
var paths = new List<string>();
var newPathArray = newPath.Split('/');
foreach (var word in this.CurrentPath.Substring(0, this.CurrentPath.Length))
{
paths.Add(word.ToString());
}
for (var counter = 0; counter < newPathArray.Length; counter = counter + 1)
{
if (newPathArray[counter] == "..")
{
paths.RemoveAt(paths.Count - 2);
paths.RemoveAt(paths.Count - 1);
}
else if(newPathArray[counter].Length > 0)
{
paths.Add("/");
paths.Add(newPathArray[counter]);
}
}
return new Path(String.Join("", paths.ToArray()));
}
示例12: CleanupList
public static List<string> CleanupList(List<string> l, bool cleanDupes)
{
// clone list first
l = new List<string>(l);
for (int x = 0; x < l.Count; x++)
{
l[x] = l[x].Trim();
if (l[x].Length == 0)
{
l.RemoveAt(x--);
}
else if (cleanDupes)
{
for (int y = 0; y < x; y++)
{
if (l[y].Equals(l[x]))
{
l.RemoveAt(x--);
break;
}
}
}
}
l.TrimExcess();
return l;
}
示例13: Callback
private void Callback(object obj)
{
if (sideVar >= 0)
{
ResetFilter ();
List<GVar> _vars = new List<GVar>();
if (sideVarLocation == VariableLocation.Global)
{
_vars = vars;
}
else
{
_vars = KickStarter.localVariables.localVars;
}
GVar tempVar = _vars[sideVar];
switch (obj.ToString ())
{
case "Insert after":
Undo.RecordObject (this, "Insert variable");
_vars.Insert (sideVar+1, new GVar (GetIDArray (_vars)));
DeactivateAllVars ();
break;
case "Delete":
Undo.RecordObject (this, "Delete variable");
_vars.RemoveAt (sideVar);
DeactivateAllVars ();
break;
case "Move up":
Undo.RecordObject (this, "Move variable up");
_vars.RemoveAt (sideVar);
_vars.Insert (sideVar-1, tempVar);
break;
case "Move down":
Undo.RecordObject (this, "Move variable down");
_vars.RemoveAt (sideVar);
_vars.Insert (sideVar+1, tempVar);
break;
}
}
sideVar = -1;
if (sideVarLocation == AC.VariableLocation.Global)
{
EditorUtility.SetDirty (this);
AssetDatabase.SaveAssets ();
}
else
{
if (KickStarter.localVariables)
{
EditorUtility.SetDirty (KickStarter.localVariables);
}
}
}
示例14: CreatBinaryTree
/// <summary>
/// 创建一颗二叉树
/// </summary>
/// <param name="list"></param>
/// <param name="root"></param>
/// <returns></returns>
public static TreeNode CreatBinaryTree(List<int> list, TreeNode root)
{
if (list.Count > 0)
{
root.left = new TreeNode(list[0]);
list.RemoveAt(0);
}
else
{
return root;
}
if (list.Count > 0)
{
root.right = new TreeNode(list[0]);
list.RemoveAt(0);
}
else
{
return root;
}
CreatBinaryTree(list, root.left);
return root;
}
示例15: Start
void Start()
{
float cos = Mathf.Cos(maxAngle);
MeshFilter MF = GetComponent<MeshFilter>();
MeshCollider MC = GetComponent<MeshCollider>();
if (MF == null || MC == null || MF.sharedMesh == null)
{
Debug.LogError("PlatformCollision needs a MeshFilter and a MeshCollider");
return;
}
Mesh M = new Mesh();
Vector3[] verts = MF.sharedMesh.vertices;
List<int> triangles = new List<int>(MF.sharedMesh.triangles);
for (int i = triangles.Count - 1; i >= 0; i -= 3)
{
Vector3 P1 = transform.TransformPoint(verts[triangles[i - 2]]);
Vector3 P2 = transform.TransformPoint(verts[triangles[i - 1]]);
Vector3 P3 = transform.TransformPoint(verts[triangles[i]]);
Vector3 faceNormal = Vector3.Cross(P3 - P2, P1 - P2).normalized;
if (Vector3.Dot(faceNormal, Vector3.up) <= cos)
{
triangles.RemoveAt(i);
triangles.RemoveAt(i - 1);
triangles.RemoveAt(i - 2);
}
}
M.vertices = verts;
M.triangles = triangles.ToArray();
MC.sharedMesh = M;
}