本文整理汇总了C#中List.Reverse方法的典型用法代码示例。如果您正苦于以下问题:C# List.Reverse方法的具体用法?C# List.Reverse怎么用?C# List.Reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List.Reverse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateMessageTable
/// <summary>
/// Formats the table of Messages based on the given list of Messages and colors.
/// </summary>
/// <param name="messages">The list of messages to display in the table</param>
/// <param name="backColors">The list of alternating background colors to display in the table</param>
/// <param name="textColors">The list of alternating text colors to display in the table</param>
public void PopulateMessageTable(List<ActivEarth.Objects.Groups.Message> messages, Color[] backColors, Color[] textColors)
{
int colorIndex = 0;
int textIndex = 0;
messages.Reverse();
foreach (ActivEarth.Objects.Groups.Message message in messages)
{
_wall.Rows.Add(MakeRowForTable(message, backColors[colorIndex], textColors[textIndex]));
colorIndex++;
if (colorIndex == backColors.Length)
{
colorIndex = 0;
}
textIndex++;
if (textIndex == textColors.Length)
{
textIndex = 0;
}
}
messages.Reverse();
_wall.Width = new Unit(80, UnitType.Percentage);
}
示例2: FromResolveResult
public static InitializerPath FromResolveResult(ResolveResult resolveResult)
{
InitializerPath initializerPath = null;
var memberPath = new List<IMember>();
var currentResolveResult = resolveResult;
do {
if (currentResolveResult is MemberResolveResult) {
var memberResolveResult = (MemberResolveResult)currentResolveResult;
memberPath.Add(memberResolveResult.Member);
currentResolveResult = memberResolveResult.TargetResult;
} else if (currentResolveResult is LocalResolveResult) {
var localResolveResult = (LocalResolveResult)currentResolveResult;
memberPath.Reverse();
initializerPath = new InitializerPath(localResolveResult.Variable) {
MemberPath = memberPath
};
break;
} else if (currentResolveResult is ThisResolveResult) {
break;
} else {
return null;
}
} while (currentResolveResult != null);
if (initializerPath == null) {
// This path is rooted at a member
memberPath.Reverse();
initializerPath = new InitializerPath(memberPath [0]) {
MemberPath = memberPath.Skip(1).ToList()
};
}
return initializerPath;
}
示例3: Main
static void Main()
{
Console.Write("Enter 16-bit signed number: ");
int number = int.Parse(Console.ReadLine());
string binaryNumber = "";
List<int> digits = new List<int>();
if (number >= 0)
{
while (number != 0)
{
digits.Add(number % 2);
number /= 2;
}
digits.Reverse();
for (int i = 0; i < digits.Count; i++)
{
binaryNumber += digits[i];
}
while (binaryNumber.Length % 16 != 0)
{
binaryNumber = "0" + binaryNumber;
}
}
else
{
number = Math.Abs(number) - 1;
while (number != 0)
{
digits.Add(number % 2);
number /= 2;
}
digits.Reverse();
for (int i = 0; i < digits.Count; i++)
{
if (digits[i] == 0)
{
binaryNumber += "1";
}
else
{
binaryNumber += "0";
}
}
while (binaryNumber.Length % 16 != 0)
{
binaryNumber = "1" + binaryNumber;
}
}
Console.Write("Result: ");
Console.WriteLine(binaryNumber);
}
示例4: GraphicsPathTest
public GraphicsPathTest()
{
_thickPen = new Pen(Microsoft.Xna.Framework.Color.Green, 15);
List<CCVector2> path1 = new List<CCVector2>() {
new CCVector2(50, 50), new CCVector2(100, 50), new CCVector2(100, 100), new CCVector2(50, 100),
};
_gpathf = new GraphicsPath(_thickPen, path1, PathType.Closed);
path1.Reverse();
for (int i = 0; i < path1.Count; i++)
path1[i] = new CCVector2(path1[i].X + 100, path1[i].Y);
_gpathr = new GraphicsPath(_thickPen, path1, PathType.Closed);
for (int i = 0; i < path1.Count; i++)
path1[i] = new CCVector2(path1[i].X, path1[i].Y + 100);
_gpath2r = new GraphicsPath(_thickPen, path1);
path1.Reverse();
for (int i = 0; i < path1.Count; i++)
path1[i] = new CCVector2(path1[i].X - 100, path1[i].Y);
_gpath2f = new GraphicsPath(_thickPen, path1);
}
示例5: AnimateModuleExpandCoroutine
private IEnumerator AnimateModuleExpandCoroutine(bool expand)
{
_isAnimating = true;
var sprites = new List<Sprite>(ShowModuleSprites);
if (!expand)
{
sprites.Reverse();
foreach (var subsystem in Subsystems)
{
subsystem.SetActive(false);
}
}
var moduleImage = ModuleButtonGO.GetComponent<Button>();
foreach (var sprite in sprites)
{
moduleImage.image.sprite = sprite;
moduleImage.image.rectTransform.sizeDelta = new Vector2(sprite.rect.width, sprite.rect.height);
yield return new WaitForSeconds(0.03f);
}
if (expand)
{
sprites.Reverse();
foreach (var subsystem in Subsystems)
{
subsystem.SetActive(true);
}
}
_isAnimating = false;
}
示例6: FromResolveResult
public static AccessPath FromResolveResult(ResolveResult resolveResult)
{
var memberPath = new List<IMember>();
var currentResolveResult = resolveResult;
do {
if (currentResolveResult is MemberResolveResult) {
var memberResolveResult = (MemberResolveResult)currentResolveResult;
memberPath.Add(memberResolveResult.Member);
currentResolveResult = memberResolveResult.TargetResult;
} else if (currentResolveResult is LocalResolveResult) {
// This is the root variable
var localResolveResult = (LocalResolveResult)currentResolveResult;
memberPath.Reverse();
return new AccessPath(localResolveResult.Variable) {
MemberPath = memberPath
};
} else if (currentResolveResult is ThisResolveResult) {
break;
} else {
// Unsupported path
return null;
}
} while (currentResolveResult != null);
memberPath.Reverse();
return new AccessPath(null) {
MemberPath = memberPath
};
}
示例7: Setup
public override void Setup (GraphicsDevice device)
{
_thickPen = new Pen(Color.Green, 15);
List<Vector2> path1 = new List<Vector2>() {
new Vector2(50, 50), new Vector2(100, 50), new Vector2(100, 100), new Vector2(50, 100),
};
_gpathf = new GraphicsPath(_thickPen, path1, PathType.Closed);
path1.Reverse();
for (int i = 0; i < path1.Count; i++)
path1[i] = new Vector2(path1[i].X + 100, path1[i].Y);
_gpathr = new GraphicsPath(_thickPen, path1, PathType.Closed);
for (int i = 0; i < path1.Count; i++)
path1[i] = new Vector2(path1[i].X, path1[i].Y + 100);
_gpath2r = new GraphicsPath(_thickPen, path1);
path1.Reverse();
for (int i = 0; i < path1.Count; i++)
path1[i] = new Vector2(path1[i].X - 100, path1[i].Y);
_gpath2f = new GraphicsPath(_thickPen, path1);
}
示例8: Main
static void Main(string[] args)
{
var arguments = new List<string>(args);
var input = new List<string>();
if (Console.IsInputRedirected)
{
string line;
while ((line = Console.ReadLine()) != null)
{
input.Add(line);
}
}
if (!arguments.Any())
{
//PrintHelp();
return;
}
var fromEnd = false;
if (arguments.Contains("-e"))
{
arguments.Remove("-e");
fromEnd = true;
}
int take;
if (!int.TryParse(arguments[0], out take))
{
return;
}
arguments.RemoveAt(0);
var tempList = new List<string>(input);
if (fromEnd)
{
tempList.Reverse();
}
if (take < 0)
{
take = tempList.Count + take;
}
tempList =
//take < 0 ? tempList.Skip(tempList.Count + take).ToList() :
tempList.Take(take).ToList();
if (fromEnd)
{
tempList.Reverse();
}
foreach (var line in tempList)
{
Console.WriteLine(line);
}
}
示例9: Main
static void Main(string[] args)
{
Console.Write("Enter 16-bit signed number: ");
int number = int.Parse(Console.ReadLine());
List<int> digits = new List<int>();
if (number >= 0)
{
while (number != 0)
{
digits.Add(number % 2);
number /= 2;
}
while (digits.Count % 16 != 0)
{
digits.Add(0);
}
digits.Reverse();
}
else
{
number = Math.Abs(number) - 1;
while (number != 0)
{
digits.Add(number % 2);
number /= 2;
}
List<int> negativeNumber = new List<int>();
for (int i = 0; i < digits.Count; i++)
{
if (digits[i] == 0)
{
negativeNumber.Add(1);
}
else
{
negativeNumber.Add(0);
}
}
digits = negativeNumber;
while (digits.Count % 16 != 0)
{
digits.Add(1);
}
digits.Reverse();
}
Console.Write("Binary representation: ");
foreach (var item in digits)
{
Console.Write(item);
}
Console.WriteLine();
}
示例10: Main
static void Main()
{
int number = int.Parse(Console.ReadLine());
List<int> binNumber = new List<int>();
StringBuilder binary = new StringBuilder();
if (number > 0)
{
while (number > 0)
{
binNumber.Add(number % 2);
number /= 2;
}
while (binNumber.Count % 16 != 0)
{
binNumber.Add(0);
}
binNumber.Reverse();
for (int i = 0; i < binNumber.Count; i++)
{
binary.Append(binNumber[i]);
}
Console.WriteLine(binary);
}
else
{
number = Math.Abs(number) - 1;
while(number>0)
{
binNumber.Add(number % 2);
number /= 2;
}
while (binNumber.Count % 16 != 0)
{
binNumber.Add(0);
}
binNumber.Reverse();
for (int i = 0; i < binNumber.Count; i++)
{
if (binNumber[i] == 0)
{
binary.Append(1);
}
else
{
binary.Append(0);
}
}
Console.WriteLine(binary);
}
}
示例11: handleDone
protected void handleDone(List<FmriRequest> reqList, Table dest, string status, Color bg, Color fg)
{
reqList.Reverse();
foreach (FmriRequest req in reqList)
{
TableRow r = new TableRow();
r.Height = 40;
TableCell c;
c = new TableCell();
c.Text = status;
c.BackColor = bg;
c.ForeColor = fg;
r.Cells.Add(c);
AddCells(r.Cells, req);
c = new TableCell();
c.Text = Convert.ToString(req.TimeExecuted);
r.Cells.Add(c);
c = new TableCell();
if (req.Result.Contains("Out of memory"))
{
req.Result = "Out of memory.";
}
if (req.Result.Trim() != "OK")
{
c.ForeColor = Color.Red;
}
c.Text = req.Result;
r.Cells.Add(c);
if (req.Result.Trim() == "OK")
{
c = new TableCell();
c.Text = "<a href=\"Results.aspx?id=" + req.AreaStringWithThresholdMD5 + "&id2=" + req.AreaStringMD5 + "\" class=\"small orange awesome\">Results</a>";
r.Cells.Add(c);
c = new TableCell();
c.Text = "<a href=\"Excel/" + req.AreaStringMD5 + ".csv\"\" class=\"small awesome\">Excel</a> <a href=\"Excel/" + req.AreaStringMD5 + ".zip\"\" class=\"small awesome\">Zipped</a>";
r.Cells.Add(c);
c = new TableCell();
c.Text = "<a href=\"Cliques/" + req.AreaStringWithThresholdMD5 + ".txt\"\" class=\"small awesome\">Cliques</a>";
r.Cells.Add(c);
}
dest.Rows.Add(r);
}
reqList.Reverse();
}
示例12: putKeyWordInCache
public static void putKeyWordInCache(string keyword,string section)
{
if (File.Exists(filePath.KEYWORDFILEPATH))
{
StringBuilder temp = new StringBuilder(KEYWORDLENGTH);
int re = GetPrivateProfileString(section, "history", "", temp, KEYWORDLENGTH, filePath.KEYWORDFILEPATH);
string t = temp.ToString();
char[] chSplit = ",".ToCharArray();
string[] key = t.Split(chSplit);
List<string> keyList = new List<string>(key);
if (keyList.Contains(keyword))
{
if (keyword != keyList[0])
{
keyList.Remove(keyword);
keyList.Reverse();
keyList.Add(keyword);
keyList.Reverse();
}
}
else
{
if (keyList.Count() == CACHESIZE)
{
keyList.Remove(keyList[CACHESIZE - 1]);
}
keyList.Reverse();
keyList.Add(keyword);
keyList.Reverse();
}
string value = null;
foreach (string s in keyList)
{
if (keyList.Last() != s)
value += s + ",";
else
value += s;
}
WritePrivateProfileString(section, "history", value, filePath.KEYWORDFILEPATH);
}
}
示例13: Main
static void Main(string[] args)
{
using (StreamReader reader = File.OpenText(args[0]))
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
if (null == line)
continue;
string[] Timestamps = line.Trim().Split(' ');
Dictionary<int, string> output = new Dictionary<int, string>();
List<int> timediff = new List<int>();
foreach(string item in Timestamps)
{
string[] hhmmss = item.Split(':');
int time = Convert.ToInt32(hhmmss[0]) * 3600 + Convert.ToInt32(hhmmss[1]) * 60 + Convert.ToInt32(hhmmss[2]);
output.Add(time,item);
timediff.Add(time);
}
timediff.Sort();
timediff.Reverse();
foreach(var item in timediff)
{
Console.Write(output[item]+' ');
}
Console.WriteLine();
}
}
示例14: PathViewModel
public PathViewModel(RepositoryNavigationRequest request, AbstractTreeNode node)
{
Elements = new List<Element>();
CurrentItem = new Element(
new RepositoryNavigationRequest(request) { Path = node.Path },
request.Treeish,
node);
var currentNode = node;
while (currentNode.Parent != null)
{
currentNode = currentNode.Parent;
if (currentNode.Parent != null)
{
Elements.Add(
new Element(new RepositoryNavigationRequest(request) { Path = currentNode.Path },
request.Treeish,
currentNode));
}
}
Elements = new List<Element>(Elements.Reverse());
Root = new Element(request, request.Treeish, currentNode);
IsRootEqualToCurrentItem = (currentNode == node);
}
示例15: Start
public override void Start()
{
if (_actuator.Actuators.Count < 2)
{
return;
}
Frames.Clear();
var orderedActuators = new List<IStateMachine>(_actuator.Actuators);
if (!_isForward)
{
orderedActuators.Reverse();
}
double frameLength = _duration.TotalMilliseconds/(orderedActuators.Count - 1);
for (int i = 0; i < orderedActuators.Count; i++)
{
var actuator = orderedActuators[i];
var offset = TimeSpan.FromMilliseconds(frameLength * i);
WithFrame(new Frame().WithTargetState(actuator, _targetState).WithStartTime(offset));
}
var lastFrame = new Frame().WithStartTime(_duration);
foreach (var actuator in _actuator.Actuators)
{
lastFrame.WithTargetState(actuator, _targetState);
}
WithFrame(lastFrame);
base.Start();
}