本文整理汇总了C#中LinkedList.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# LinkedList.CopyTo方法的具体用法?C# LinkedList.CopyTo怎么用?C# LinkedList.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList
的用法示例。
在下文中一共展示了LinkedList.CopyTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: rasteriza
public static Point[] rasteriza(Point ini, Point fim) {
LinkedList<Point> points = new LinkedList<Point>(); //Guardara os pontos criados
float len;
if (Math.Abs(fim.x - ini.x) >= Math.Abs(fim.y - ini.y)) {
len = Math.Abs(fim.x - ini.x);
} else {
len = Math.Abs(fim.y - ini.y);
}
float deltax = (fim.x - ini.x) / len;
float deltay = (fim.y - ini.y) / len;
float x = ini.x;
float y = ini.y;
for (int i = 0; i < len; i++) {
points.AddLast(new Point((int) Math.Floor(x), (int) Math.Floor(y)));
x += deltax;
y += deltay;
}
points.AddLast(new Point((int) Math.Floor(x), (int) Math.Floor(y)));
Point[] ret = new Point[points.Count];
points.CopyTo(ret, 0);
return ret;
}
示例2: CopyTo_Zero_Index
public void CopyTo_Zero_Index(int[] testCase)
{
LinkedList<int> list = new LinkedList<int>();
foreach (int data in testCase)
{
list.AddLast(data);
}
int[] newArray = new int[testCase.Length];
list.CopyTo(newArray, 0);
Assert.AreEqual(testCase, newArray, "The resulting array was not correct");
}
示例3: Sort
public static TriMesh.HalfEdge[] Sort(LinkedList<TriMesh.Edge> src)
{
LinkedList<TriMesh.HalfEdge> dst = new LinkedList<HalfEdgeMesh.HalfEdge>();
dst.AddLast(src.First.Value.HalfEdge0);
src.RemoveFirst();
LinkedListNode<TriMesh.Edge> node = src.First;
int count = 0;
while (node != null)
{
TriMesh.Vertex first = dst.First.Value.FromVertex;
TriMesh.Vertex last = dst.Last.Value.ToVertex;
if (node.Value.Vertex0 == first)
{
dst.AddFirst(node.Value.HalfEdge0);
src.Remove(node);
count++;
}
else if (node.Value.Vertex1 == first)
{
dst.AddFirst(node.Value.HalfEdge1);
src.Remove(node);
count++;
}
else if (node.Value.Vertex0 == last)
{
dst.AddLast(node.Value.HalfEdge1);
src.Remove(node);
count++;
}
else if (node.Value.Vertex1 == last)
{
dst.AddLast(node.Value.HalfEdge0);
src.Remove(node);
count++;
}
node = node.Next;
if (node == null && count != 0)
{
node = src.First;
count = 0;
}
}
TriMesh.HalfEdge[] arr = new HalfEdgeMesh.HalfEdge[dst.Count];
dst.CopyTo(arr, 0);
return arr;
}
示例4: CopyTo_Nth_Index
public void CopyTo_Nth_Index(int[] testCase)
{
LinkedList<int> list = new LinkedList<int>();
foreach (int data in testCase)
{
list.AddLast(data);
}
int preOffset = (DateTime.Now.Millisecond % 20) + 1;
int postOffset = preOffset;
int[] newArray = new int[preOffset + testCase.Length + postOffset];
list.CopyTo(newArray, preOffset);
for (int i = preOffset, x = 0; i < (preOffset + testCase.Length); i++, x++)
{
Assert.AreEqual(testCase[x], newArray[i], "The expected value was not correct");
}
}
示例5: EmitBlock
/// <summary>
/// Converts a ProgramBlock to C.
/// </summary>
/// <param name="block">ProgramBlock to convert.</param>
/// <returns>ProgramBlock in C.</returns>
public string[] EmitBlock(ProgramBlock block)
{
LinkedList<string> blockList = new LinkedList<string>();
string[] blockSource;
blockList.AddLast("{");
foreach (IProgramChunk chunk in block.Program)
{
foreach(string line in EmitChunk(chunk))
blockList.AddLast(line);
}
blockList.AddLast("}");
blockSource = new string[blockList.Count];
blockList.CopyTo(blockSource, 0);
return blockSource;
}
示例6: Subdivide
public static Vector2D[] Subdivide(Vector2D[] vertexes, Scalar maxLength, bool loop)
{
if (vertexes == null) { throw new ArgumentNullException("vertexes"); }
if (vertexes.Length < 2) { throw new ArgumentOutOfRangeException("vertexes"); }
if (maxLength <= 0) { throw new ArgumentOutOfRangeException("maxLength"); }
LinkedList<Vector2D> list = new LinkedList<Vector2D>(vertexes);
LinkedListNode<Vector2D> node = list.First;
while (node != null)
{
Vector2D line;
if (node.Next == null)
{
if (!loop) { break; }
line = list.First.Value - node.Value;
}
else
{
line = node.Next.Value - node.Value;
}
Scalar mag;
Vector2D.GetMagnitude(ref line, out mag);
if (mag > maxLength)
{
int count = (int)MathHelper.Ceiling(mag / maxLength);
mag = mag / (mag * count);
Vector2D.Multiply(ref line, ref mag, out line);
for (int pos = 1; pos < count; ++pos)
{
node = list.AddAfter(node, line + node.Value);
}
}
node = node.Next;
}
Vector2D[] result = new Vector2D[list.Count];
list.CopyTo(result, 0);
return result;
}
示例7: CopyToTest
public void CopyToTest ()
{
int [] values = new int [] { 2, 3, 4 };
int [] output = new int [3];
intlist.CopyTo (output, 0);
for (int i = 0; i < 3; i++)
Assert.AreEqual (values [i], output [i]);
LinkedList <int> l = new LinkedList <int> ();
values = new int [l.Count];
l.CopyTo (values, 0);
}
示例8: parseFolder
/**
* Faz o parser do caminho.
*/
private string[] parseFolder(String basePath)
{
LinkedList<string> result = new LinkedList<string>();
String s;
if (basePath.StartsWith("/"))
s = basePath.Substring(1);
else
s = basePath;
while (s.Length > 0 && s.EndsWith("/"))
{
s = s.Substring(0, s.Length - 1);
}
while (s.Length > 0)
{
if (s.IndexOf("/") > 0)
{
result.AddLast(s.Substring(0, s.IndexOf("/")));
s = s.Substring(s.IndexOf("/") + 1);
}
else
{
result.AddLast(s);
s = "";
}
}
string s1 = result.ElementAt(result.Count - 1);
result.RemoveLast();
string[] s2 = parseCode(s1);
for (int i = 0; i < s2.Length; i++)
{
result.AddLast(s2[i]);
}
string[] sArray = new string[result.Count];
result.CopyTo(sArray, 0);
return sArray;
}
示例9: parseCode
/**
* Faz o parser do código do item para criar as pastas.
*/
private string[] parseCode(string code)
{
LinkedList<string> result = new LinkedList<string>();
char[] cs = code.ToLower().ToCharArray();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < cs.Length; i++)
{
if ((cs[i] >= '0' && cs[i] <= '9') || (cs[i] >= 'a' && cs[i] <= 'z'))
{
if (sb.Length > 0)
sb.Append("/");
sb.Append(new string(cs[i], 1));
result.AddLast(new string(cs[i], 1));
}
}
for (int i = 0; i < code.Length - 1; i++)
{
string c = code.Substring(i, 1);
}
LOG.imprimeLog(System.DateTime.Now + " ===== Estrutura Pastas: " + sb.ToString());
string[] sArray = new string[result.Count];
result.CopyTo(sArray, 0);
return sArray;
}
示例10: AddHolesSymbols
//.........这里部分代码省略.........
}
}
}
}
plinfoidx += 2 + (int)plinfo[plinfoidx + 1] + 7 +
(int)plinfo[plinfoidx + 2 + (int)plinfo[plinfoidx + 1] + 6] * 3;
}
if (drwHoles.Count > 0)
{
var drwHolesArr = new DrawingHole[drwHoles.Count];
int holeidx = 0;
foreach (DrawingHole drwhole in drwHoles)
{
drwHolesArr[holeidx] = drwhole;
holeidx++;
}
string holeFileName = DrwPathResult + "holes.txt";
var drwHoleBlocks = new LinkedList<DrawingHoleBlock>();
if (File.Exists(holeFileName))
{
var reader = new StreamReader(holeFileName, Encoding.GetEncoding(1251));
string line;
while ((line = reader.ReadLine()) != null)
{
string[] linearr = line.Split('\t');
try
{
drwHoleBlocks.AddLast(
new DrawingHoleBlock(DrwPathResult + linearr[2],
Convert.ToDouble(linearr[0]) / 2000,
Convert.ToDouble(linearr[1]) / 1000));
}
catch
{
}
}
reader.Close();
}
var drwHoleBlocksArr = new DrawingHoleBlock[drwHoleBlocks.Count];
drwHoleBlocks.CopyTo(drwHoleBlocksArr, 0);
string[] blocknames = Directory.GetFiles(DrwPathResult, "*.SLDBLK");
int blockidx = 0;
for (int i = 0; i < drwHolesArr.Length; i++)
{
if (!drwHolesArr[i].IsProcessed)
{
string blockname = "";
foreach (DrawingHoleBlock t in drwHoleBlocksArr)
{
if (t.Radius == drwHolesArr[i].Radius &&
t.Depth == drwHolesArr[i].Depth)
{
blockname = t.BlockFileName;
break;
}
}
if (blockname == "")
{
while (blocknames.Length > blockidx)
{
blockname = blocknames[blockidx];
blockidx++;
string blockname1 = blockname;
if (drwHoleBlocksArr.Any(t => t.BlockFileName.ToLower() == blockname1.ToLower()))
{
blockname = "";
}
if (blockname != "")
break;
}
}
ProcessHole(swView, drwHolesArr[i], blockname);
for (int j = i + 1; j < drwHolesArr.Length; j++)
{
if (!drwHolesArr[j].IsProcessed && drwHolesArr[i].Radius == drwHolesArr[j].Radius &&
drwHolesArr[i].Depth == drwHolesArr[j].Depth)
{
ProcessHole(swView, drwHolesArr[j], blockname);
}
}
}
}
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message, MyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
示例11: Format
/// <summary>
/// Форматирует слово в соответствии с переданным значением.
/// </summary>
/// <param name="aValue">Число, в зависимости от которого форматируется слово.</param>
/// <param name="aKey">Начало ключа словоформ в ресурсах.</param>
/// <param name="isContact">Нужно ли соединить слово с числительным.</param>
/// <returns>Отформатированная строка.</returns>
public string Format(int aValue, string aKey, bool isContact)
{
if (aValue <= 0)
throw new ArgumentOutOfRangeException("Число должно быть положительным.");
if (aKey == null)
throw new ArgumentNullException("Ключ не должен быть null.");
LinkedList<string> wordList = new LinkedList<string>();
//Ищем все словоформы для данного ключа
int index = 0;
string word = null;
while ((word = Properties.Resources.ResourceManager
.GetString(aKey + "_" + index, culture)) != null)
{
index++;
wordList.AddLast(word);
}
//Конвертируем в массив
string[] words = new string[wordList.Count];
wordList.CopyTo(words, 0);
//Форматируем
return formatter.Format(aValue, words, isContact);
}
示例12: CreateCells
private void CreateCells(ref LinkedListNode<Token> tokenNode)
{
tokenNode = tokenNode.Next;
LinkedList<ICell> Cells = new LinkedList<ICell>();
Cell cell = null;
while (tokenNode.Value.Tag != Tag.CELLS_END)
{
Token token = tokenNode.Value;
switch (tokenNode.Value.Tag)
{
case Tag.CELL_ID: cell = new Cell(((Num)token).Value.ToString());
break;
case Tag.CELL_SITENAME: cell.SiteName = ((StringBlock)token).value;
break;
case Tag.CELL_SECTOR: cell.Sector = ((Num)token).Value;
break;
case Tag.CELL_TRAFFIC: cell.Traffic = ((Num)token).Value;
break;
case Tag.CELL_LOCALLY_BLOCKED: cell.LocallyBlocked = ((NumArray)token).Value;
break;
case Tag.CELL_LOCATION: cell.Location = CreateLocation(((StringBlock)token).value);
break;
case Tag.CELL_INNER_END: Cells.AddLast(cell);
break;
}
tokenNode = tokenNode.Next;
}
this.Cells = new ICell[Cells.Count];
Cells.CopyTo(this.Cells,0);
}
示例13: CopyList
public static LinkedList<Payment> CopyList(LinkedList<Payment> clist)
{
Payment[] tmpArray = new Payment[clist.Count];
clist.CopyTo(tmpArray, 0);
return new LinkedList<Payment>(tmpArray);
}
示例14: Analyze
void Analyze(LinkedList<Statement> Statements)
{
Statement[] Stmts = new Statement[Statements.Count];
Statements.CopyTo(Stmts, 0);
for (int i = 0; i < Stmts.Length; i++)
{
if (Stmts[i] != null) Analyze(Stmts[i]);
}
}
示例15: Deserialize
/// <summary>
/// Deserializes a player from a stream.
/// </summary>
/// <param name="s">The stream to extract the player from.</param>
/// <returns>The player found, or null if EOF</returns>
public static Player Deserialize(Stream s)
{
Player p = new Player();
LinkedList<byte> nameMaker = new LinkedList<byte>();
UTF8Encoding utf = new UTF8Encoding();
int nextByte = s.ReadByte();
if ( nextByte == -1 )
return null;
//Read in all the bytes until 0 byte.
while ( nextByte > 0 ) {
nameMaker.AddLast( (byte)nextByte );
nextByte = s.ReadByte();
}
//Make sure we keep UTF8 compat
byte[] convert = new byte[nameMaker.Count];
nameMaker.CopyTo( convert, 0 );
p.nick = utf.GetString( convert );
//Read the money
convert = new byte[88];
s.Read( convert, 0, 88 );
p.money = BitConverter.ToUInt64( convert, 0 );
//Read the stats
p.blackjacks = BitConverter.ToUInt64( convert, 8 );
p.hands = BitConverter.ToUInt64( convert, 16 );
p.wins = BitConverter.ToUInt64( convert, 24 );
p.ties = BitConverter.ToUInt64( convert, 32 );
p.highestMoney = BitConverter.ToUInt64( convert, 40 );
p.busts = BitConverter.ToUInt64( convert, 48 );
p.splits = BitConverter.ToUInt64( convert, 56 );
p.dds = BitConverter.ToUInt64( convert, 64 );
p.surrenders = BitConverter.ToUInt64( convert, 72 );
p.moneyResets = BitConverter.ToUInt64( convert, 80 );
return p;
}