rchillyard / The-repository-formerly-known-as

2 stars 12 forks source link

Alternative solution to Issue #30 #38

Closed rchillyard closed 4 years ago

rchillyard commented 4 years ago

In this solution, the encoding of set of objects into long[] results in a Coding (new class) which gives the longs and whether coding was perfect or not. BaseHuskySequenceCoder (new class): the huskyEncode for X[] instantiates new long array and checks for perfect encoding (but only as long as is perfect); HuskySequenceCoder: removed perfect(X) and isPerfectCallable() methods; HuskyHelper: initLongArray has been renamed as doCoding and now it uses the huskyEncode method of HuskyCoder; HuskyCoderFactory: updated to use base coder classes for sequence coders;

rchillyard commented 4 years ago

This implementation uses the method that I suggested for Issue #30. It seems to run very slightly slower than the base branch of this PR. However, I didn't do an exhaustive set of benchmarks. The logic of this method is much better, IMO. I would like someone to take a look.

rchillyard commented 4 years ago

Yes, @Sraw , I wondered that myself. At some point, we might try concretizing the class hierarchy to eliminate run-time polymorphism. I think that's going to be a very minor cost but definitely good to keep it in mind. Thanks for the approval. Others?