|
Hi Guffa,
I take some time to study your article. It is not big, but clear enough, cool! I like it!
A few comments,
1.
Why you use inner class to implement the comparer interface? Why not just let the parking special key class implements the comparer interface directly? Any benefits?
2.
I want to confirm with you that,
when we use Hashtable, Object.Equals and Object.GetHashCode is used. But when we use Dictionary, IEqualityComparer.Equals and IEqualityComparer.GetHashCode is used?
3.
Equality comparer of the Dictionary is what is used as the 1st parameter of the Dictonary constructor, like your inner class ParkingSpaceKey.EqualityComparer?
regards,
George
|
|
|
|
|
|
Thanks Alan,
I think it is more correct to say Hashtable is a special type of Dictionary, whose key type is Object, correct?
regards,
George
|
|
|
|
|
I think it's the other way around. A hashtable is a specific type of data structure whose key can be anything that can be represented as binary.
A Dictionary is an object that performs a function, and it can be implemented with a hashtable or other data structures. Often you see this functionality implemented with a red-black tree which can grow dynamically (e.g. in C++'s STL), as opposed to a hashtable which has a fixed size.
|
|
|
|
|
Thanks Alan,
Alan Balkany wrote: as opposed to a hashtable which has a fixed size.
You mean Hashtable does not grow? I think when we insert elements into Hashtable, it grows.
Any comments?
regards,
George
|
|
|
|
|
A hashtable has a fixed size. When it gets too full its performance degrades, so one strategy is to then create a bigger one, and reinsert all the elements into it.
This has some overhead. Normally a hashtable allows insertion and retrieval in constant time. When the hashtable has to grow regularly, it can increase the time for insertion to O(n) or higher, depending on how often it happens.
|
|
|
|
|
Thanks Alan,
1.
Alan Balkany wrote: A hashtable has a fixed size. When it gets too full its performance degrades, so one strategy is to then create a bigger one, and reinsert all the elements into it.
I am confused what do you mean fixed size. I think from developer point of view, we can insert as much elements as possible into Hashtable, so no feel of limitation of fixed size. Any more descriptions or pseudo code please?
2.
Alan Balkany wrote: When the hashtable has to grow regularly, it can increase the time for insertion to O(n) or higher, depending on how often it happens.
What means grow regularly? Why the performance degrades? Could you provide more description please?
(reference document link is also ok, I am interested in this topic)
regards,
George
|
|
|
|
|
Here's link that explains more: http://en.wikipedia.org/wiki/Hash_table[^]
Hashing transforms a key into the address of a slot to store the data in. There are a fixed number of slots. When multiple keys are mapped to the same slot, there are different ways of handling it, all of which take time.
Type "hash table" into Google, and you'll get much more than I can explain here.
|
|
|
|
|
How about my question item 1?
--------------------
I am confused what do you mean fixed size. I think from developer point of view, we can insert as much elements as possible into Hashtable, so no feel of limitation of fixed size. Any more descriptions or pseudo code please?
--------------------
Fixed size means limited size?
regards,
George
|
|
|
|
|
Look at the link I gave, type "hash table" into Google and look at some of those references, and see if they answer your questions. There's a lot of material on hash tables out there, with more complete explanations than I can give you here.
|
|
|
|
|
Thanks Alan,
I read the link, clarified a lot of things. I often heard people talk about re-hash, does it mean the same thing of "Table resizing" in the link you mentioned?
regards,
George
|
|
|
|
|
It might. I haven't heard that term in the context of hash tables.
|
|
|
|
|
Thanks Alan,
Your reply is clear. I want to check why do you think before Hashtable is fixed size? If the load factor is large enough (e.g. HashMap in Java is 75%), it will be resized to increase its size -- so not fixed. Could you clarify please?
regards,
George
|
|
|
|
|
If you increase the size of the hash table, you also have to change the hashing function to produce keys for this larger size. When you do this, the elements you've already added to the hash table must go to different slots. So every element must be re-inserted in the new larger table.
This process creates a new hash table and replaces the old one. The old one wasn't resized.
|
|
|
|
|
Thanks Alan,
So, the root cause is hash function is dependent on table size?
regards,
George
|
|
|
|
|
|
Thanks Alan!
You mentioned before -- "When the hashtable has to grow regularly, it can increase the time for insertion to O(n) or higher, depending on how often it happens.". "It" means?
regards,
George
|
|
|
|
|
Growing regularly. Every time the hashtable "grows", all elements that have been inserted must be reinserted into the new hashtable. When a hashtable has n elements, it takes n operations to copy them, as opposed to a single operation to insert one element.
|
|
|
|
|
Thanks Alan!
Question answered. You are so patience.
regards,
George
|
|
|
|
|
hello everybody,
I have just finished my senior project and I want to make the installation file that always called (SETUP.exe). so is there any tools that make it directly or should I produce it manualy by VS new project and use the IO library to copy the files to 'program files' folder??
I am using VS.NET 2005 c#.
thanks alot...
|
|
|
|
|
Genius.Boy,
You can use the "Setup project" in VS. I cant remember off hand, but its something like:
New Project -> Setup and Deployment
This will allow you to create an installer for your exe.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Thanks alot Mr. Gareth. it is very helpful
iam gonna work with it
thanks again.
.
Genius.Boy
|
|
|
|
|
does anyone know how to do this?
Another guy in the office developed a document management system which uses custom file attributes to get the name, revision, drawer etc of some pdf drawings. It was written in vb6 and we've previously had vba cad macros that export the drawings to pdf with the attributes filled out.
we've moved to new drawing software and I'm making the new version of the exporting to pdf, its in C# now, I've got it all sorted but I am stumped on how to make custom file attributes...
I've got a FileInfo on one of the PDF files, but the Attributes property only allows you to set attributes from the FileAttributes enumeration which has things like Hidden, Archive, ReadOnly etc.
How do you set an attribute that is not a part of that enumeration? if there is no way to do it in .net is there a dll i can import from windows api or something?
There's a GetFileVersionInfo function you can import from version.dll (windows 32 com/sdk?) to find the "version" of files, but we've got custom attributes like "DocRevis" ...
Surely there is a way to do it?
|
|
|
|
|
|
Hello everyone,
I want to get the same time in yesterday, is there any bug in my below code?
My concern is code, _CurrentDate.Now.Day - 1, if current date is 1, 1 minus 1 is zero, not a valid date?
DateTime _CurrentDate = DateTime.Now;
DateTime _LastDate = new DateTime(_CurrentDate.Now.Year, _CurrentDate.Now.Month, _CurrentDate.Now.Day - 1, _CurrentDate.Now.Hour, _CurrentDate.Now.Second);
thanks in advance,
George
|
|
|
|