|
Thanks Guffa,
I have got your idea.
When we remove an item from Dictionary, the slot is still there and referred to NULL.
My question is, whether the slot will be reused when we insert
1. any new key/value pair?
Or
2. only new key/value pair which has the same key value as the previously deleted item?
regards,
George
|
|
|
|
|
When you remove an item from a dictionary, the entry is placed in a bucket of unused entries. These entries are reused when adding any new items to the dictionary.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks Guffa,
Good to learn it is always reusable for the deleted slots, no matter whether or not the original key value of the deleted item is the same as the key value of the new inserted item.
regards,
George
|
|
|
|
|
1. I'm fairly sure that the capacity of the Dictionary will not be reduced when items are removed, but Dictionary doesn't have a Capacity property to check (unlike List).
Personally, I would not consider the memory used by items in the Dictionary as part of the Dictionary's footprint; after all, an instance of some class may be in several collections at once.
If the Dictionary holds the only reference to a particular instance and you remove that item, the instance will be garbage collected (at some point later).
2. With a List you can Remove entries and then set .Capacity to trim off the excess, not so with Dictionary.
|
|
|
|
|
Great PIEBALDconsult!
For 1,
From your analysis, if I removed the item from Dictionary, the item will be GCed (if no other reference), right?
My confusion is why do you think the capacity of Dictionary will not be impacted after item removal?
For 2,
I am confused. How can you use .Capacity to restrict the size of the List? We can continue to insert and the List will continue to grow, right? Correct me if I do not understand your points correctly.
regards,
George
|
|
|
|
|
1) I think of Lists and Dictionaries as merely a dynamic bunch of slots, the number of slots is the capacity, more slots will be added as needed. Removing the contents of a slot doesn't remove the slot, something else may be put in that slot later.
Plus, each slot doesn't contain the actual contents, only a reference to the contents. (Even with value types.)
2) It doesn't restrict it, it can still grow afterward.
But if you use a List to collect a bunch of things, and then remove many of them from the List, trimming the excess may be a good idea if you aren't going to add a bunch more items.
|
|
|
|
|
Thanks PIEBALDconsult,
Great! You always have wonderful answers which brings me further insights.
1.
For Dictionay, when we call Remove, the slots will still be there. When we add elements later, will the slots be resued?
2.
For Dictionary, for the slots which is empty (pointing to NULL reference) because of removed elements, are they avaliable to be reused for any new inserted elements or the slots are binded to special key hash value (which special key element can reuse)?
3.
PIEBALDconsult wrote: trimming the excess may be a good idea
Do you mean trim the empty slots? Which API in List class perform slot trim function?
regards,
George
|
|
|
|
|
Hi all,
I'm new to the C# and .Net programming, but I've got experience in other programming languages such as C, C++ and Java.
I need access to webcam for capturing video and to process each frame in real time.
I've read several articles about it and seen how to access to the webcam with avicap32.dll but I'd like to know if there's a better way.
Thanks for your attention
|
|
|
|
|
I would expect that DirectX is the way to go, only thing is, Managed DX is very lame. There are better wrappers for DX around on the web that expose more functionality. Ultimately, you're going to be p/invoking DX because C# itself isn't going to do this for you.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Christian,
I've tried with directX already, in particular with namespaces Microsoft.DirectX and Microsoft.DirectX.DirectInput I've coded a simple method for enumerating the devices connected to the system but it doesn't show me the webcam.
On msdn I've seen that the directx are used for build games and managed devices are joystick, mouse and keyboard.
How can I do it ?
Thanks
|
|
|
|
|
DirectInput is used for things like keyboards, mice, joysticks, etc. You actually want DirectBlow DirectShow, and you have to build a filter, blah blah blah (you'll swear you're in hell when you start testing with other web cams). I hate DirectShow.
EDIT - a quick search on Google led me to this:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1339&lngWId=10[^]
And there's even an article here on CP:
http://www.codeproject.com/KB/audio-video/cameraviewer.aspx[^]
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Saturday, May 17, 2008 8:42 AM
|
|
|
|
|
Hi John,
I've already read these articles and the problem of the 1th approach is that it used the system's Clipboard to save the frames. What I really need, I think, is to access to the frames still in memory to process and elaborate them. So, Is there a way to save frames in data structure such as a Bitmap object without saving the frame on disk?
|
|
|
|
|
Well, the first one captures data every x milliseconds, so I suppose it's okay to use the clipboard, but I agree- it seems clunky. It looks like you're going to have to go through DirectShow (or whatever they're calling it now).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The issue is that by using the clipboard I disable the copy&paste functionality. The DirectShow applications must be written in C++ but I've to use C#.
|
|
|
|
|
maresp1982 wrote: he DirectShow applications must be written in C++ but I've to use C#.
I'm pretty sure you can use PInvoke to do your DirectShow calls. There shouldn't be any reason to use C++ (un-managed code).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
Is that meant to be a question ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
prakash_adysoft wrote: crawler how to work
what does it mean ?
|
|
|
|
|
|
prakash_adysoft wrote: crawler how to work
When somebody can't walk properly (possibly because they've had too much to drink), then they sometimes fall to all fours. This is how a crawler works.
|
|
|
|
|
i need daniel carvalho liedke s mail
|
|
|
|
|
Never heard of him. Not sure why you'd assume that anyone who read this would have his email, or know who he is. If he wrote an article, you can email him using the email he gave the site, via his article. If he posted here, you can email him via his posts.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi guys,
i want to validate the xml file using DTD in C#.net. can u send me the sample C#.net code to validate the xml file..
Cheers
velu
d.sengottuvelu
|
|
|
|
|
System.Xml.XmlReaderSettings.ProhibitDtd = false (But I don't use DTDs.)
|
|
|
|
|
Hi,
I need to Convert DWG file to .X file.Is that possible??Because DWG is a CAD file format and .X is DirectX file format.Kindly give me some useful information regarding my issue.
Regards,
Priya
|
|
|
|