本文整理汇总了C#中System.Collections.Generic.List.Reverse方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.List.Reverse方法的具体用法?C# System.Collections.Generic.List.Reverse怎么用?C# System.Collections.Generic.List.Reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.List
的用法示例。
在下文中一共展示了System.Collections.Generic.List.Reverse方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: each_object
internal int each_object(Class klass, Frame caller, Proc block)
{
int n = 0;
System.GC.Collect();
ObjectSpace.objects.RemoveAll(delegate(System.WeakReference r) { return !r.IsAlive; });
System.Collections.Generic.List<System.WeakReference> copy = new System.Collections.Generic.List<System.WeakReference>(ObjectSpace.objects);
copy.Reverse();
foreach (System.WeakReference r in copy)
if (klass == null || Class.CLASS_OF(r.Target).is_kind_of(klass))
{
if (r.Target is Class && ((Class)r.Target)._type == Class.Type.IClass || ((Class)r.Target)._type == Class.Type.Singleton)
continue;
Proc.rb_yield(block, caller, r.Target);
n++;
}
return n;
}
示例2: LoadThumbnail
/// <summary>
/// Loads the thumbnail of the loaded image file, if any.
/// </summary>
/// <param name="binReader">A BinaryReader that points the loaded file byte stream.</param>
/// <param name="pfPixelFormat">A PixelFormat value indicating what pixel format to use when loading the thumbnail.</param>
private void LoadThumbnail(BinaryReader binReader, PixelFormat pfPixelFormat)
{
// read the Thumbnail image data into a byte array
// take into account stride has to be a multiple of 4
// use padding to make sure multiple of 4
byte[] data = null;
if (binReader != null && binReader.BaseStream != null && binReader.BaseStream.Length > 0 && binReader.BaseStream.CanSeek == true)
{
if (this.ExtensionArea.PostageStampOffset > 0)
{
// seek to the beginning of the image data using the ImageDataOffset value
binReader.BaseStream.Seek(this.ExtensionArea.PostageStampOffset, SeekOrigin.Begin);
int iWidth = (int)binReader.ReadByte();
int iHeight = (int)binReader.ReadByte();
int iStride = ((iWidth * (int)this.objTargaHeader.PixelDepth + 31) & ~31) >> 3; // width in bytes
int iPadding = iStride - (((iWidth * (int)this.objTargaHeader.PixelDepth) + 7) / 8);
System.Collections.Generic.List<System.Collections.Generic.List<byte>> objRows = new System.Collections.Generic.List<System.Collections.Generic.List<byte>>();
System.Collections.Generic.List<byte> objRow = new System.Collections.Generic.List<byte>();
byte[] padding = new byte[iPadding];
MemoryStream msData = null;
bool blnEachRowReverse = false;
bool blnRowsReverse = false;
using (msData = new MemoryStream())
{
// get the size in bytes of each row in the image
int intImageRowByteSize = iWidth * ((int)this.objTargaHeader.PixelDepth / 8);
// get the size in bytes of the whole image
int intImageByteSize = intImageRowByteSize * iHeight;
// thumbnails are never compressed
for (int i = 0; i < iHeight; i++)
{
for (int j = 0; j < intImageRowByteSize; j++)
{
objRow.Add(binReader.ReadByte());
}
objRows.Add(objRow);
objRow = new System.Collections.Generic.List<byte>();
}
switch (this.objTargaHeader.FirstPixelDestination)
{
case FirstPixelDestination.TOP_LEFT:
break;
case FirstPixelDestination.TOP_RIGHT:
blnRowsReverse = false;
blnEachRowReverse = false;
break;
case FirstPixelDestination.BOTTOM_LEFT:
break;
case FirstPixelDestination.BOTTOM_RIGHT:
case FirstPixelDestination.UNKNOWN:
blnRowsReverse = true;
blnEachRowReverse = false;
break;
}
if (blnRowsReverse == true)
objRows.Reverse();
for (int i = 0; i < objRows.Count; i++)
{
if (blnEachRowReverse == true)
objRows[i].Reverse();
byte[] brow = objRows[i].ToArray();
msData.Write(brow, 0, brow.Length);
msData.Write(padding, 0, padding.Length);
}
data = msData.ToArray();
}
if (data != null && data.Length > 0)
{
this.ThumbnailByteHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
this.bmpImageThumbnail = new Bitmap(iWidth, iHeight, iStride, pfPixelFormat,
this.ThumbnailByteHandle.AddrOfPinnedObject());
}
}
else
{
//.........这里部分代码省略.........
示例3: RefreshStatus
void RefreshStatus()
{
System.Collections.IList projects;
try {
projects = (System.Collections.IList) CallApi ("/projects");
}
catch(Exception e)
{
Console.Error.WriteLine (e);
ScheduleRefresh ();
return;
}
int numberOfProjects = projects.Count;
System.Collections.Generic.IList<System.Collections.IDictionary> projectsList = new System.Collections.Generic.List<System.Collections.IDictionary> ();
foreach(System.Collections.IDictionary project in projects)
{
projectsList.Add (project);
}
projectsList = projectsList.OrderBy(x=>x["reponame"]).ToList();
projectsList.Reverse ();
foreach (Gtk.ImageMenuItem oldMenuItem in projectMenuItems) {
menu.Remove (oldMenuItem);
}
projectMenuItems.Clear ();
bool allGreen = true;
foreach(System.Collections.IDictionary project in projects)
{
String statusString = null;
System.Collections.IDictionary branches = (System.Collections.IDictionary) project["branches"];
if (branches != null) {
System.Collections.IDictionary develop = (System.Collections.IDictionary) branches["develop"];
if (develop != null) {
System.Collections.IList recent_builds = (System.Collections.IList) develop ["recent_builds"];
if (recent_builds != null && recent_builds.Count > 0) {
System.Collections.IDictionary last_build = (System.Collections.IDictionary) recent_builds[0];
String status = (String) last_build ["status"];
if ("success".Equals (status)) {
statusString = "✓";
}
else if ("failed".Equals (status)) {
statusString = "✗";
allGreen = false;
}
}
}
}
if (statusString != null) {
String projectName = (String) project["reponame"];
// https://circleci.com/gh/transcovo/API-Node/tree/develop
String projectUrl = "https://circleci.com/gh/" +
((String)project ["username"]) + "/" +
projectName + "/tree/develop";
ImageMenuItem newMenuItem = new Gtk.ImageMenuItem (statusString + " " + projectName);
newMenuItem.Activated += (object sender, EventArgs e) => System.Diagnostics.Process.Start (projectUrl);
projectMenuItems.Add (newMenuItem);
menu.Insert(newMenuItem, 0);
}
}
menu.ShowAll ();
if (allGreen) {
indicator.IconName = greenFilePath;
} else {
indicator.IconName = redFilePath;
}
ScheduleRefresh ();
}
示例4: LoadImageBytes
//.........这里部分代码省略.........
}
}
#endregion
}
else
{
#region NON-COMPRESSED
// loop through each row in the image
for (int i = 0; i < (int)this.objTargaHeader.Height; i++)
{
// loop through each byte in the row
for (int j = 0; j < intImageRowByteSize; j++)
{
// add the byte to the row
row.Add(binReader.ReadByte());
}
// add row to the list of rows
rows.Add(row);
// create a new row
row = null;
row = new System.Collections.Generic.List<byte>();
}
#endregion
}
// flag that states whether or not to reverse the location of all rows.
bool blnRowsReverse = false;
// flag that states whether or not to reverse the bytes in each row.
bool blnEachRowReverse = false;
// use FirstPixelDestination to determine the alignment of the
// image data byte
switch (this.objTargaHeader.FirstPixelDestination)
{
case FirstPixelDestination.TOP_LEFT:
blnRowsReverse = false;
blnEachRowReverse = true;
break;
case FirstPixelDestination.TOP_RIGHT:
blnRowsReverse = false;
blnEachRowReverse = false;
break;
case FirstPixelDestination.BOTTOM_LEFT:
blnRowsReverse = true;
blnEachRowReverse = true;
break;
case FirstPixelDestination.BOTTOM_RIGHT:
case FirstPixelDestination.UNKNOWN:
blnRowsReverse = true;
blnEachRowReverse = false;
break;
}
// write the bytes from each row into a memory stream and get the
示例5: encodeUI64
public static System.Collections.Generic.List<byte> encodeUI64(ulong v)
{
byte[] bin = System.BitConverter.GetBytes(v);
var ret = new System.Collections.Generic.List<byte>(bin);
if (!System.BitConverter.IsLittleEndian)
ret.Reverse();
return ret;
}
示例6: GetNodeBreadcrumbs
public string[] GetNodeBreadcrumbs(int nodeId)
{
AuthorizeRequest(true);
var node = new cms.businesslogic.CMSNode(nodeId);
var crumbs = new System.Collections.Generic.List<string>() { node.Text };
while (node != null && node.Level > 1)
{
node = node.Parent;
crumbs.Add(node.Text);
}
crumbs.Reverse();
return crumbs.ToArray();
}
示例7: DoubleToBase
public static PhpBytes DoubleToBase(double number, int toBase)
{
if (toBase < 2 || toBase > 36)
{
PhpException.InvalidArgument("toBase", LibResources.GetString("arg:out_of_bounds"));
return PhpBytes.Empty;
}
// Don't try to convert infinity or NaN:
if (Double.IsInfinity(number) || Double.IsNaN(number))
{
PhpException.InvalidArgument("number", LibResources.GetString("arg:out_of_bounds"));
return PhpBytes.Empty;
}
double fvalue = Math.Floor(number); /* floor it just in case */
if (Math.Abs(fvalue) < 1) return new PhpBytes(new byte[]{(byte)'0'});
System.Collections.Generic.List<byte> sb = new System.Collections.Generic.List<byte>();
while (Math.Abs(fvalue) >= 1)
{
double mod = Fmod(fvalue, toBase);
int i = (int)mod;
byte b = digits[i];
//sb.Append(digits[(int) fmod(fvalue, toBase)]);
sb.Add(b);
fvalue /= toBase;
}
sb.Reverse();
return new PhpBytes(sb.ToArray());
}
示例8: SeparateDigits
/// <summary>
/// Separates out the individual digits in an integer into a list
/// Requires a positive number
/// </summary>
public static System.Collections.Generic.List<int> SeparateDigits(int number)
{
Assert.IsTrue(number > 0);
var digitsList = new System.Collections.Generic.List<int>();
while (number > 0)
{
digitsList.Add(number % 10);
number = number / 10;
}
digitsList.Reverse();
return digitsList;
}
示例9: InitContextMenu
//.........这里部分代码省略.........
mitHelp.Header = Comisor.Resource.Help + "(_H)";
mitHelp.Click += new RoutedEventHandler((o, e) => { ShowHelpBox(); });
#endregion
#region Exit
mitExit.Header = Comisor.Resource.Exit + "(_X)";
mitExit.Click += new RoutedEventHandler((o, e) => { CloseWindow(); });
#endregion
#region Bookmark
mitBookmark.Header = Comisor.Resource.Bookmark + "(_B)";
mitBookmark.ToolTip = Comisor.Resource.Bookmark_c;
#region Init Add button and textbox
ComboBox cbAdd = new ComboBox();
MenuItem mitAdd = new MenuItem();
cbAdd.MinWidth = 120;
cbAdd.HorizontalAlignment = HorizontalAlignment.Left;
cbAdd.IsEditable = true;
btnAddBookmark.Content = main.resource.imgPlus;
btnAddBookmark.Margin = new Thickness(2);
mitAdd.StaysOpenOnClick = true;
mitAdd.Icon = btnAddBookmark;
mitAdd.Header = cbAdd;
mitBookmark.Items.Add(mitAdd);
mitBookmark.Items.Add(new Separator());
mitBookmark.SubmenuOpened += (o, e) =>
{
System.Collections.Generic.List<string> nameOption = new System.Collections.Generic.List<string>();
nameOption.AddRange(imgInfo.FullName.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries));
ys.DataProcessor.RemoveSame(ref nameOption);
nameOption.Reverse();
cbAdd.ItemsSource = nameOption;
cbAdd.SelectedIndex = 0;
cbAdd.Focus();
};
cbAdd.PreviewKeyDown += (o, e) =>
{
if (e.Key == Key.Enter)
{
btnAddBookmark.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, btnAddBookmark));
}
};
btnAddBookmark.Click += (o, e) =>
{
if (e.OriginalSource is string) cbAdd.Text = e.OriginalSource as string;
Bookmark bk = new Bookmark(cbAdd.Text, imgInfo.FullName);
bookmarks.Insert(0, bk);
Button btnDelete = new Button();
Label lbName = new Label();
MenuItem mit = new MenuItem();
btnDelete.Content = main.resource.imgMinuts;
btnDelete.Margin = new Thickness(2);
btnDelete.Click += (oo, ee) =>
{
bookmarks.Remove(bk);
mitBookmark.Items.Remove(mit);
};
lbName.Content = cbAdd.Text;
mit.Icon = btnDelete;