I have a non-general-purpose object that only exists to be in collections. A library I'm writing that defines the object, let's call it Collected
, and two implementations of the collection, that should have advantages in different scenarios. Let's call them Collection1
and Collection2
. The collection is central to high-speed processing in this application so let's say performance is paramount.
The code for Collected
is identical between the two, except 1) the ctor param that takes its collection, and 2) the member variable storing it.
So, I'm tempted to replace Collected
with TemplatedCollected<class T>
with the obvious code change. Apps using the library could decide centrally which they want, and either define MyCollected
as TemplatedCollected<Collection1>
or TemplatedCollected<Collection2>
.
However if there is any chance it is any faster, I could make a Collected1
and Collected2
class that are identical except which collection they support. (Again, the app could define MyCollected
to their needs.)
Aucun commentaire:
Enregistrer un commentaire