I have a file that contains a sorted list of key/value pairs. The key is a fixed-length string, and the value is the binary representation of an integer. So if the key size were 6, each record is exactly 10 bytes (6+sizeof(int)). The key size can be any (reasonable) value but is the same for every record in the file.
For example, the data file might look like this (where 'xxxx' would be binary representations of int values):
ABLE xxxxBAKER xxxxCARL xxxxDELTA xxxxEDGAR xxxxGEORGExxxx
I would like to load this table into memory (a byte[]) and binary search it. In C++, this is a snap, the bsearch() function takes an 'element size' parameter that tells it the size of the records in the buffer, but I cannot find a similar function in C#.
I've also looked at Array.BinarySearch, but I can't figure out what I'd use as a T.
byte[](that is, an array of byte arrays), then theTparameter inArray.BinarySearch<T>()would bebyte[]structthat more or less wraps accurately over it and useSpans to access it, but this at best reduces memory use, and still incurs overhead for decoding the strings and comparing them, so it would not generally win over simply parsing the file -- being "binary" doesn't give it any kind of special status there.