Search related threads. Remove From My Forums. Answered by:. Archived Forums V. Visual C Language. Sign in to vote. Remove From My Forums.
Asked by:. Archived Forums. Getting Started with ASP. NET question on a topic that's not covered by one of the other more specific forums - ask it here. Sign in to vote.
So, in general, a sorted list will generally be faster for small data sets. As the data set becomes large, the growth of the list's search time overshadows the fixed overhead of hashing, and the hash table becomes faster.
Where that breakpoint is will vary depending on your specific hash table and sorted-list-search implementations. Run tests and benchmark performance on a number of typically-sized data sets to see which will actually perform better in your particular case.
Or, if the code already runs "fast enough", don't. Just use whichever you're more comfortable with and don't worry about optimizing something which doesn't need to be optimized. In some cases, it depends on the size of the collection and to a lesser degree, implementation details.
If your list is very small, items maybe, I'd guess the list would be faster. Otherwise xtofl has it right. HashTable would be more efficient for list containing more than 10 items. If the list has fewer than 10 items, the overhead due to hashing algo will be more. In case you need a fast dictionary but also need to keep the items in an ordered fashion use the OrderedDictionary.
Net 2. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Add "Jacob","" ; sampletable. Add "Stacy", "" ; sampletable. Add "Kelly", "" ; sampletable. Add "Mike", "" ; sampletable.
Add "Carla", "" ; sampletable. WriteLine "If Mike exists? Remove "Carla" ; Console. In the above example a Hashtable named sampletable has been declared. Some items have been added in this hashtable in the form of key-value pairs via add function.
0コメント