Open jordanelder opened 8 years ago
Related to #133
We've kicked this idea around a couple of times, but we always end up getting stuck on how/whether to implement things like hash code computation, equality comparison, operator<
, &c. on Bond structs. Doing so would be mechanical but there are enough cases where the mechanical implementations aren't the right thing to do.
A middle-group approach would be to allow blobs as keys. Then, with use of type aliases, maps/dictionaries with non-scalar keys could be constructed. This would enable efficient representations for many structs, but put the burden of conversion to/from objects and the selection and implementation of hashing/comparison algorithms on the user of Bond.
Would that be enough for your cases--or does it leave too much up to you?
@chwarr The middle approach seems reasonable since maps/dictionaries have O(1) access, insert and delete time. I am trying hard to implement it. Could you explain the approach a little in detail from an implementation standpoint?
@nehulyadav, not sure whether the middle approach is the actual way to go. Haven't done much thinking in this area lately.
Off the top of my head, the following changes would be needed:
I am working on a schema in which Guids are used as the keys in maps. I am doing this by creating a type alias between Guid and string, and using a BondTypeAliasConverter class to convert them.
I would like to be able to use the Bond.GUID struct as a map key instead of a string, so that the binary serialized output is more compact.