Καλώς ορίσατε στο dotNETZone.gr - Σύνδεση | Εγγραφή | Βοήθεια

Παρουσίαση με Ετικέτες

Όλες οι Ετικέτε... » fun   (RSS)

Duff Device on Wikipedia

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DuffDeviceFun
{
    class Program
    {
        static void DuffDevice(byte[] src, byte[] dest, int count)
        {

            unsafe
            {
                fixed (byte* fromp = src, top = dest)
                {
                    byte* from = fromp;
                    byte* to = top;
                    int n = (count + 7) / 8;
                    switch (count % 8)
                    {
                        case 0: goto LBL0;
                        case 7: goto LBL7;
                        case 6: goto LBL6;
                        case 5: goto LBL5;
                        case 4: goto LBL4;
                        case 3: goto LBL3;
                        case 2: goto LBL2;
                        case 1: goto LBL1;
                    }
                LBL0: *to++ = *from++;
                LBL7: *to++ = *from++;
                LBL6: *to++ = *from++;
                LBL5: *to++ = *from++;
                LBL4: *to++ = *from++;
                LBL3: *to++ = *from++;
                LBL2: *to++ = *from++;
                LBL1: *to++ = *from++;
                    if (--n > 0)
                        goto LBL0;
                }
            }
        }
        static void Main(string[] args)
        {
            string msg = "Demo Message!";
            var len = msg.Length * sizeof(char);
            byte[] from = new byte[len];
            Buffer.BlockCopy(msg.ToCharArray(), 0, from, 0, len);
            byte[] to = new byte[from.Length * sizeof(char)];
            DuffDevice(from, to, len);
            char[] res = new char[to.Length / sizeof(char)];
            Buffer.BlockCopy(to, 0, res, 0, to.Length );
            Console.WriteLine(res);
            Console.ReadKey();
        }
    }
}
0 σχόλια
Δημοσίευση στην κατηγορία: , , ,
Ψαχνόμουν χθες λίγο το βραδάκι και έπεσα πάνω σε ένα Plugin για τον IE7. "IE7Pro is a must have add-on for Internet Explorer, which includes a lot of features and tweaks to make your IE friendlier, more useful, secure and customizable. IE7Pro includes Tabbed Browsing Management, Spell Check, Inline Search, Super Drag Drop, Crash Recovery, Proxy Switcher, Mouse Gesture, Tab History

Διαβάστε περισσότερα »

0 σχόλια
Δημοσίευση στην κατηγορία: , , , ,