Just because someone helped a person who asked a specific question, doesn't mean he'll do your homework. Imagine what this forum would look like if every person with a question started to hijack threads ?
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
Ignore the others - I'll help you. Of course, you'll have to pay the daily rates my company charges, but what the hell - we'll throw in a years support contract for a very reasonable fee. We will expect an initial payment before work commences, but once we have the contract in place, we'll be good to go.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
Are you a cool kid who wants to impress your friends and family with your mad skillz?
If you think you're a "cool" kid who can impress people with 1337 programming skillz0r then you really need to go outside. I knew from the beginning that programming wasn't going to make me the life of a party, it's not right for Microsoft to lie to kids this way.
and you can still capture it if you install a keyboard hook.
This is a bit late, I know, but I am having terrible problems with my ISP at the moment (I'm stuck on 53.6 kbps at the moment, when I can get a connection that is ).
My point was that Alt-Space is one of the less well known keyboard shortcuts but nonetheless some people do use it (me for instance) and because of that it might be worth the OP considering an alternative. There is little that is worse than using a 'standard' shortcut only to find that the app you are using has decided to use it for formatting the C: drive.
As far as I am aware you can capture any key combo with a global hook but whether you should is another thing.
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I'm sorry about your connection speed but I had a laugh.
Henry Minute wrote:
My point was that Alt-Space is one of the less well known keyboard shortcuts but nonetheless some people do use it (me for instance) and because of that it might be worth the OP considering an alternative.
There are many valid reasons to execute code when the user is pressing this key combo (amongst many other combos). For instance, if your application does not have a system menu, and you want to emulate it yourself. Or your application is largely ownerdrawn (we have an app where there's just one window and everything else is drawn as bitmaps in runtime) and it emulates a lot of stuff (context menu drawing, system menu drawing, cursor, etc.,) based on keyboard and mouse inputs. This can be done only with the help of a hook. And this is not going to affect the way other applications work (you execute your code, only if your window is active).
Henry Minute wrote:
As far as I am aware you can capture any key combo with a global hook
Not any key combo. The SAS (Ctrl+Alt+Del) key combo is not something that can be trapped because it triggers a hardware interrupt that isn't notified of outside the ring0 level. (OK, may be that can as well be trapped, but that will require ninja windows programming skills). Even with ninja skills, it is almost impossible to trap it on x64 versions of Windows, because of Kernel Patch Protection.
I am not sure how to express what I need. However...
I've got a code which generates all permutations of an array of numbers 0 to n-1, which can be used to generate permutations of any array, since every element can be mapped to it's index and vice versa.
Here it is:
public IEnumerable<int> GetPermutations()
if (n == 1)
var generator = new PermutationGenerator(n - 1); // recursionbool even = false;
foreach (int permutation in generator.GetPermutations())
for (int i = 0; i < n; i++)
yieldreturn InsertN(permutation, i);
elsefor (int i = n - 1; i >= 0; i--)
yieldreturn InsertN(permutation, i);
even = !even;
In an algorithm I am currently writing, sometimes it is good to skip some permutations. E.g. I have reached , and realize that I don't need any perm. which starts with [123.....], so I would like to skip 5! permutations and go in one step to [124.....]. It basically means that I would like to put a "return" in a given level of recursion. The code would look like this I suppose:
I was thinking of that, but like I said, hard to wrap my brain around your algorithm right about now...
What you could do is set a boolean flag on your generator class in the SkipPermutations function... And in GetPermutations(), you can "yield return 0" instead of running a block of code whenever you want to skip an entry. I'm not sure where exactly to put it though.
Basically MoveNext() will continue GetPermutations() until it hits the next "yield" statement. If it's a "yield return", it'll set the Current property to the result and return true... If it's a "yield break", it'll return false. So you just need GetPermutations() to "yield return 0" until the skip flag is turned off.
Very interesting read... I wonder how practical it would be in these terms though, given the processing needed to keep resizing a list in that manner... With an array, you'd have to either keep resizing it or mark+skip zeroes every time you pick out a number... With a linked list, you've got ridiculous allocation times...
There has to be a data structure that'd scale well enough, because those factoradic numbers seem like a great way to iterate...
I read through the Wikipedia article... Didn't see the implementation.
Once you actually generate the factoradic number, you still need to grab the items from the array... Like in their example:
Step 1: Take element #4 and remove it from the array
Array: 0,1,2,3,5,6 <--- Resized, which would be too slow for an array OR
Array: 0,1,2,3,_,5,6 <--- Marked to skip
Step 2: Take element #0 and remove it
Step 3: Take element #4 and remove it
Can see the issue in the third step... The #4 element is actually the sixth because we removed two... So you can't just access an array index (First address + (element size x index)), which would be lightning quick... You have to count through the array like you're iterating through a linked list.
So basically, once you generate the factoradic, building the permutation is 6+5+4+3+2+1 (In whatever order) steps, or n(n+1)/2... an O(n^2) operation.
(The only good part about that method is that you can actually use a boolean array to mark the flags and clear it in one memory operation for the next pass)
Then if you're generating ALL possible permutations, it's an O(n^3) operation.
So I'm trying to think of a data structure that would chop that n^2 down a bit.