|
Covean wrote: I just found it funny to not be limited and then limit the get function to int.
Right, I should think forward -- maybe some time we will measure memory in peta- or exa-bytes .
Covean wrote: return (ulong)1 << (i & 0x000000000000003F);
Nice, thanks... (no, not nice in a south park meaning[^]).
Greetings - Jacek
|
|
|
|
|
Cool video, thanks for that.
Greetings
Covean
|
|
|
|
|
Covean wrote: mov cl, dl
movzx rax, bit
This is a real pain in C# - we have to do div and mod seperately and therefore do the same operation twice, since cpu returns both values from div command.
Greetings - Jacek
|
|
|
|
|
Another mark: << operator can be used only for ints or smaller types. For uint/long/ulong it produces compile-time error .
Greetings - Jacek
|
|
|
|
|
Jacek Gajek wrote: << operator can be used only for ints or smaller
not correct; you can do long << int which is what you need; simply do the AND instead of the modulo, cast to int, then shift.
optimum = no table, no method, just a few in-line statements.
|
|
|
|
|
Jacek Gajek wrote:
My question: Is there any sens in caching masks? that is: {0x0, 0x1, 0x2,... ,0x10, 0x20,....0x100000...}. It would take 0,5 kB.
Only on old CPU's that don't have a single cycle shift by cl
Also, I would really ditch the % and / and use & and >> instead. The optimizer of the JIT compiler does optimize divisions and modulo's by constants, but for signed integers (even when it's trivial to prove that they can not be negative at that point) it wants to perfectly match real modulo en real division (which is not needed since it's not going to be negative anyway)
like: return (table[bit >> 6] & (1ul << bit)) != 0
edit: removed the redundant & 63
|
|
|
|
|
I liked the previous version more
harold aptroot wrote: edit: removed the redundant & 63
Why redundant? What if bit=213? I should look at 21th bit of 3rd integer. That is, table[2] & (1ul << 21) ;
Greetings - Jacek
|
|
|
|
|
Bitwise shifts in C# do an implicit shiftamount & (BITSIZE - 1)
Actually x86's do that already by themselves, provided that you used the right operand size (which is always the case for 64bit shifts, but the JIT compiler emits the and instruction anyway)
|
|
|
|
|
Dear Developers..
I need to generate a (.acb) file,which ll be used in photoshop.
like other .acb files by photoshop.
I think i have to user dll which give methods to convert file in acb format..
Please give me some sugggestion,hints..!
Thanking you
|
|
|
|
|
hi friends!!
i just wanted to know is there a way to inflate a region in GDI+, i am creating a region
on runtime using mouse_up event, then i get the region ; now i want to inflate it how can a
acheieve it? i have tried matrixtransformation + scale, is there some other way??
Thanks in Advance
Samir
|
|
|
|
|
hi all
i want to compare two xml files. does any one having code for this.
any hint ????
thanks in advance
koolprasad2003
Rating always..... WELCOME
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
hi,
Are both the files having same structure i.e common tags ,
in this case if you use a class serialization method to read this XML file it can be very handy! You can create the class object of each file and actually come to know which tag is having diffent data.. hope this helps u..
Best of luck
Samir
|
|
|
|
|
Thanks for reply sameer,
both my xml files have same structure.
have u any example of class serialization to compare xml file... ??
thanks in advance
koolprasad2003
Rating always..... WELCOME
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
hi prasad,
Here a link how you use Xml serialisation in C# http://msdn.microsoft.com/en-us/library/ms950721.aspx
1)your need to build your own class as same stucture as that of the Xml
2) then populate the data in class using XmlReader and input both the files http://msdn.microsoft.com/en-us/library/system.xml.xmltextreader.aspx
3)create instances of class created with two files
4)maybe override the = operater to generate the report of what all data on which tag differ
Hope i am clear!!!
Best Of Luck Buddy!!
Samir
|
|
|
|
|
Let me get this straight.
for 2 xml files which have the same structure you would deserialize your xml into classes and override the whole map's equals functioality and then compare your 2 maps to try to determine if there are any differences.
instead of, say, just comparing the xml to each other using string comparison?
|
|
|
|
|
J4amieC wrote: instead of, say, just comparing the xml to each other using string comparison?
Come on, thats far too easy. Where's the opportunity to create abstract classes, interfaces, several layers of inheritance, sub-classes and all the rest of the bloat so it looks like we are earning our crust
Bob
Ashfield Consultants Ltd
Proud to be a Code Project MVP
|
|
|
|
|
hi, follow the two links below.
http://forums.devx.com/showthread.php?t=168067
http://www.daniweb.com/forums/thread46345.html#
best regards.
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:55am.
|
|
|
|
|
Hi,
As the subject states I'm a complete newbie in programming.
I've coded a little program that uses picture boxes to display images of dices.
After filling the picture boxes with an image a PictureBox[pictureBoxNumber].Image.Dispose() is executed.
All the loops I'm using work fine, but if I press the "Alt" or "Alt Gr" key on the keyboard after the button_Click event has run an ArgumentException gets thrown.
The stack trace doesn't make me any wiser though. I've copied it to be able to post it so here it is:
bij System.Drawing.Image.get_Width()
bij System.Drawing.Image.get_Size()
bij System.Windows.Forms.PictureBox.ImageRectangleFromSizeMode(PictureBoxSizeMode mode)
bij System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
bij System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
bij System.Windows.Forms.Control.WmPaint(Message& m)
bij System.Windows.Forms.Control.WndProc(Message& m)
bij System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bij System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bij System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bij System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bij System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
bij System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bij System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bij System.Windows.Forms.Application.Run(Form mainForm)
bij prjDices.Program.Main() in E:\Mijn documenten\Visual Studio 2008\Projects\solTeerlingen\prjTeerlingen\Program.cs:regel 18
bij System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
bij System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bij Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bij System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bij System.Threading.ThreadHelper.ThreadStart()
I've been trying to figure out what happens for quite a while now but to no avail.
I'm really completely stuck on this.
If someone could help me understand what causes the exception I'd be very thankful.
I'm not asking for a solution just help to figure out what in heaven's name is going on.
Thanks in advance,
Jeff
|
|
|
|
|
I'm curious as to why you Dispose() of the images?
they are in use in the picture box, so disposing them will lead to problems!
maybe that's even the cause (for some twisted reason) of your mysterious problem.
but do dispose of the images, ONCE you got rid of them!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Hi Super Lloyd,
Thanks for responding.
About the reason to dispose of the images.
In an application I wrote earlier a picture box control was also used.
When starting the application I also started task manager and observed what happened.
The picture boxes really eat away memory if the images are not disposed of.
Greetz and thanks,
Jeff
|
|
|
|
|
you can't successfully call Dispose() on an Image inside a PictureBox.
this would be the proper way to switch a PictureBox from image1 to image2:
Image newImage=...;
Image oldImage=pb.Image;
pb.Image=newImage;
if (oldImage!=null) oldImage.Dispose();
|
|
|
|
|
Hi Luc,
Thanks for replying.
You made me think about what was going on and yes sir problem solved.
Seeing that I disposed of the images after every loop it's quite obvious that in the next run no images were available.
The solution was actually fairly easy.
Before I dispose of the image I use a boolean expression to determine whether or not an image is present.
Like this:
if (PictureBox[pictureBoxNumber].Image != null)
{
PictureBox[pictureBoxNumber].Image.Dispose();
}
Greetz and thanks for the insight,
Jeff
|
|
|
|
|
that is not good enough, you can't dispose of that image as it is still in use by the PictureBox itself,
you really should do it the way I have shown: copy the reference to a local variable, remove the image from the PictureBox, and only then dispose of it.
modified on Friday, January 15, 2010 7:40 AM
|
|
|
|
|
Hi,
my regex works fine in a regextest tool its just only when i try to filter the content via c# it doesnt work. here is my code
string fName = @"data.txt";
part of the content that should match
<div class="middleadimggold">
<a class="asdf" href="http://www.asdf">
asdf</a>
<p>
asdf</p>
<p>asdf</p><p>asdf</p>
<p><span class="blue">asdf</span>
<a class="de" href="http://www.4asdf"><span class="a">(See on map)</span></a></p>
<p><span class="blue">asdf</span></p>
<span class="xx">
asdf
</span>
</div>
please note the spacing in the content, not sure if it matters?
modified on Thursday, January 14, 2010 10:06 PM
|
|
|
|
|
ok this fixed the problem
if (Regex.IsMatch(allRead, regMatch, RegexOptions.Singleline)
singleline option that is. thanks for nothing
|
|
|
|