delphi - Pointer to generic type -
In the process of changing the implementation of a skilled pointer-based hash map given in the implementation of a normal hash map, StumbleUpon Problem:
I have a class representing a hash node (the implementation of hash map uses binary trees)
theatrical & lt; KEY_TYPE, VALUE_TYPE & gt; = Square public key: KEY_TYPE; Price: VALUE_TYPE; Left: Thesection & lt; KEY_TYPE, VALUE_TYPE & gt ;; Correct: Download & lt; KEY_TYPE, VALUE_TYPE & gt ;; End; Additionally there is a function that should return a pointer to the hash node. I want to write
PHashNode = ^ Thashonode but it does not compile (';' but expected but found '& lt;').
How can I get an indicator for a common type?
And related to Barry Kelly: If you read it: Yes, it is based on the implementation of your hash map. You have not written this general version of your implementation, are you? This will save me some time :)
Sorry, indicators are not supported to open swipe general types Because generic pointers are not supported, although in some circumstances they are possible (compiler bug) to create them (especially the typical nested type signals); If we break someone's code then this "feature" can not be deleted in any update. The range of generic pointer types should be removed in the future, but I can not promise when <.>
If the question is typed then I have written in the JclStrHashMap (Or ancient hashlist unit), well, the easiest way to reproduce it is by changing the node type as a class and any double with pointer Points must be passed near proper casting though, if I today I was rewriting that unit, so I did not apply the bucket in bucket trees. I got a chance to write a dictionary in generic. Selection unit, however, all other delphi compilers were very tight before shipping for the solid QA at the time of the work, and the support of the generic facility was in the flux for quite a while itself.
I like to apply the hash map bucket as a list listed by double listings, per-batch dynamic arrays or a list of cells, which also came out best from the tests using representative data. . The argument is that in the tree / list, the cash of the following links should be dominated by any difference in the search of bucket between the Miss Cost and the list with a good hash function. The current dictionary is implemented directly as a linear probe because it was relatively easy to implement and worked with the available set of initial generic operations.
That said, the binary tree bucket has an effective defense against the poor hash function; If they were balanced binary trees ( = & gt; more modification costs) they would be o (1) on average and o (log n) the performance of the worst position.
Comments
Post a Comment