А-ч, vsprintf () был вещью, которую я пропускал. Я могу использовать это для передачи списка аргумента переменной непосредственно printf ():
#include <stdarg.h>
#include <stdio.h>
void DBG_PrintImpl(char * format, ...)
{
char buffer[256];
va_list args;
va_start(args, format);
vsprintf(buffer, format, args);
printf("%s", buffer);
va_end(args);
}
Тогда обертка все это в макросе.
System.Collections.Generic.Dictionary
and System.Collections.Hashtable
classes both maintain a hash table data structure internally. None of them guarantee preserving the order of items.
Leaving boxing/unboxing issues aside, most of the time, they should have very similar performance.
The primary structural difference between them is that Dictionary
relies on chaining (maintaining a list of items for each hash table bucket) to resolve collisions whereas Hashtable
uses rehashing for collision resolution (when a collision occurs, tries another hash function to map the key to a bucket).
There is little benefit to use Hashtable
class if you are targeting for .NET Framework 2.0+. It's effectively rendered obsolete by Dictionary
.
Both are effectively the same class (you can look at the disassembly). HashTable was created first before .Net had generics. Dictionary, however is a generic class and gives you strong typing benefits. I would never use HashTable since Dictionary costs you nothing to use.
Еще одно важное отличие состоит в том, что тип Hashtable поддерживает одновременное использование нескольких считывателей без блокировки и одного записывающего устройства. , а Dictionary - нет.