|
It must be December - it's time for the annual telling of the ancient "chess nuts boasting" joke.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
It probably comes as no surprise to you to find out you are the winner.
|
|
|
|
|
Xou might get it: Wizard of Id[^].
I have good connections to the guys who test these[^].
It's still not going to be cheap, but women love expensive cars.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
CodeWraith wrote: It's still not going to be cheap, but women love expensive cars.
and Jewelry and Clothes and Shopping and ...
They call me different but the truth is they're all the same!
JaxCoder.com
|
|
|
|
|
Mike Hankey wrote: and ...
Not the ones I have met, they are usually grumpy as hell during "that time"
|
|
|
|
|
Mine has to be inserts and deletions in containers implemented over arrays:
Below is some ugly code. I hate this. B-trees are FAR worse though.
bool ICollection<T>.Remove(T item)
{
if (Equals(_array[_head],item))
{
Dequeue();
return true;
}
else
{
for(var i = 0;i<_count;++i)
{
var idx = (_head + i) % _array.Length;
if(Equals(_array[idx],item))
{
if (_head + _count < _array.Length)
{
Array.Copy(_array, idx + 1, _array, idx, _count - idx - 1);
}
else if (idx == _array.Length - 1)
{
_array[idx] = _array[0];
if(_count+_head!=_array.Length)
{
Array.Copy(_array, 1, _array, 0, (_count + _head) % _array.Length - 1);
}
}
else if (idx < _head)
{
Array.Copy(_array, idx + 1, _array, idx, (_count + _head) % _array.Length - 1);
}
--_count;
unchecked
{
++_version;
}
return true;
}
}
}
return false;
}
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
I can feel the lack of love in ya code...
you can do nicer, I believe in ya!
Also there is a bug!
If T is a reference type, you would leave the reference at the head index being duplicated (and NOT garbage collected)... you should set newly empty spot to default(T)
as in, if you remove B
your underlying array will go from
A | B | C
to
A | C | C
The last C will prevent garbage collection of C
|
|
|
|
|
yeah that's true. I wasn't considering the collection of ref types there. Now I can see why microsoft cleared their arrays. I didn't put 2 and 2 together and think about garbage collection. meh. thanks.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Here you go corrected version.. though I feel I might be wrong a little bit by +/- 1 on some indexes, you gotta proof read it!
EDIT (oops got the count wrong on my removes... buut I still hope the general outline ispire you for its simplicity! )
v1
bool ICollection<T>.Remove(T item)
{
for(var i = 0; i < _count; ++i)
{
var idx = (_head + i) % _array.Length;
if(!Equals(_array[idx],item))
continue;
if (_head + _count < _array.Length)
{
Array.Copy(_array, idx + 1, _array, idx, _count - idx - 1);
}
else if (idx < _head)
{
Array.Copy(_array, idx + 1, _array, idx, ((_head + _count) % _array.Length - idx - 1));
}
else
{
Array.Copy(_array, idx + 1, _array, idx, _array.Length - idx - 1);
_array[_array.Length - 1] = _array[0];
Array.Copy(_array, 1, _array, 0, _head - 1);
}
_array[_head + _count - 1] = default(T);
--_count;
unchecked { ++_version; }
return true;
}
return false;
}
v2
bool ICollection<T>.Remove(T item)
{
var i = FindIndex(item);
if (i == -1)
return false;
var idx = (_head + i) % _array.Length;
if (_head + _count < _array.Length)
{
Array.Copy(_array, idx + 1, _array, idx, _count - idx - 1);
}
else if (idx < _head)
{
Array.Copy(_array, idx + 1, _array, idx, (_head - idx - 1));
}
else
{
Array.Copy(_array, idx + 1, _array, idx, _array.Length - idx - 1);
_array[_array.Length - 1] = _array[0];
Array.Copy(_array, 1, _array, 0, _head - 1);
}
_array[_head + _count - 1] = default(T);
--_count;
unchecked { ++_version; }
return true;
}
modified 5-Dec-19 23:11pm.
|
|
|
|
|
I didn't factor it that much just because I whipped it up so fast. It's on my TODOs, which is why it's sitting in my prelim folder.
Before I extensively factored it, I wanted to dogfood it, so I used it in my backtracking parsers.
Now that it works, and I've tested it in a real world situation, I'm ready to go back and clean it up, I just haven't gotten to it yet.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
I nominate the old (x + m) % m to avoid the old "if x is negative then % works in a weird way".
It's not big, but happens a lot, and often after a debugging session and cursing. Bad vibes.
|
|
|
|
|
To me modulo is a so second nature that I don't find it confusing it all.
When I see it, I automatically think - this is probably a bounding value for the target it is modifying.
For example:
return _array[i % _array.Length];
That tells me that i 's value is wrapped to the array's length.
It's instinct to me. What's less clear is when people use if to accomplish the same thing, IMO.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Modulo is fine, I meant the annoying pattern to deal with negative dividends. -1 % _array.Length = -1 and that's usually not what you want from a modulo.
modified 7-Dec-19 1:10am.
|
|
|
|
|
ahh, i see. =)
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
if (something)
DoSomethingOnThisLineWithoutBraces(); I never do it, but I see it a lot
|
|
|
|
|
|
No?
Why should it in your mind?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
This question, Googled, returns 108 hits which ALL have nothing to do with what is implicit to it, as a question. So, yeah, I guess "No" is really the most useful thing anyone would expect to gain by typing the question, or any question for that matter, into that pile of ... nonsense.
So thanks for this.
|
|
|
|
|
This is a good example of the hidden esoteric teaching (gematria) behind Google's search engine.
I am not allowed to say too much, but, note that 108 is a sacred number in Buddhism, and Hinduism, Sikh religion, and Jainism ... it also happens to be the hyperfactorial of 3 : sum of two squared and three cubed. Each interior angle of a pentagon is 108.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
RedDk wrote: So, yeah, I guess "No" is really the most useful thing anyone would expect to gain by typing the question, or any question for that matter, into that pile of ... nonsense. You were suggesting that the monitor should go blank/black, so I'm expecting arguments. There were none, so I'm inclined to be brief.
Give some arguments why it should, and maybe I'll explain my answer.
RedDk wrote: So thanks for this.
You're most welcome
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
This barrage of displays for instance:
https://www.codeproject.com/script/Content/ImageUploads/f4ac59dc-aa36-4cd2-b0a7-6f6553e1adeb-small.png[^]
If those images of an oil platform were, as I anticipate someone will tell me, wallpaper on a desktop, not there and only the color BLACK was being used as the background ... and no icons were present on that desktop, I would expect both monitors to power down and present a powerless, non-LCD heating, void ... that is, technically, a no-signal (though the monitor "knows" not to begin displaying a message in "pong" mode (text scurrying about an invisible set of Escher staircases on the screen) because the monitors are still connected to the graphics card which in turn is still powered by the computer to which the other two monitors are attached too)).
But if I move my cursor (mouse) through the monitors (the array of system metric or desktop dimension currently "powered") the signal would turn to power up and that cursor/pointer/whatever would be backlit by the BLACK desktop color chosen.
modified 6-Dec-19 14:19pm.
|
|
|
|
|
The monitor does not know when the mouse is moved, nor should it.
I like black screens; you can SEE that they are not broken, just displaying nothing. It is also quicker to display from "nothing" to anything then when you turn it on first.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Alright, perhaps the idiosyncratic mouse mentioned was a poor choice of a computer object to use in a description of the environment seen in the image to which I pointed.
The desktop wallpaper. Let us assume that that's what I'm seeing on that backplane there on the wall (poor choice of words, I know ... cheapness at the expense of expedience), if I were to go into "Personalize" and switch from "Background/Picture" to "Background/Solid Color/Black" I would perhaps gain no-picture and both of those displays would show BLACK as the desktop color. Yes?
Perhaps not, right? Because I see on the table where the keyboard is placed that perhaps the desktop color is lime green and there is currently an open window displaying Codeproject on a web browser and there's no oil platform anywhere behind any of the stuff displayed there. Assume now then that that lime green monitor is being designated as the MAIN DISPLAY. But perhaps not again; both of those monitors, attached to some video cards, might be primary and lime green because they are being STRETCHED (MOSAIC'D/whatever) under the control of that video card. Whatever the case might be, I'd expect whatever background displayed on the MAIN DISPLAY to always be powered up in the normal running of the OS.
Even if there was no mouse cursor being used on the MAIN DISPLAY?
That is not a possibility is it? No icons; a possibility.
Anyway ... to put a period where a period is due in this thread, if on one of many extraneous monitors attached to one or more video cards on one computer, there were no icons, no toolbars, no open windows, etc ... I would expect that the blackness (yes I refer directly to the background "Solid Color" chosen in the "Personalize" dialog) would usurp any tendency for that monitor to actively display any signs of being powered-on ... and appear completely signalless and dark.
|
|
|
|
|
RedDk wrote: if I were to go into "Personalize" and switch from "Background/Picture" to "Background/Solid Color/Black" I would perhaps gain no-picture and both of those displays would show BLACK as the desktop color. Yes? Yes; which makes it harder to see if the system is standby, and should not even be an option.
RedDk wrote: would usurp any tendency for that monitor to actively display any signs of being powered-on ... and appear completely signalless and dark. You mean to say "play dead".
It's a missed opportunity; a screensaver could display a lot of useful information. As for playing dead, I would not buy it, simple as that. If it is on, it should display what the signal tells it to. Once screensaver-functionality comes to the display, it will not be used to power it off, but to display Google-ads.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Ok, I'll bite.
"System in standby" By that you imply what ... that a screensaver is running? That ... the background (Windows 10) black is being displayed?
Flat out: in Windows Server 2008 R2 Ent and under the guise of a couple of PCIe video cards of various obsolete datelines of various manufacture and mixed monitor types/screen size/manufacture ... black was NOT displayed. Meaning all monitors with the exception of the MAIN DISPLAY (where the taskbar resides), powered down. That is, again, no signal, no heat, no nothing, todt, dead, fertig.
But pass a mouse through that dead desktop space and bingo ... power up ... white arrow. Return to MAIN DISPLAY, down go the houselights back there, no heat, dead.
|
|
|
|
|