multiton

How to create a class that doesn't re-create an object with identical input parameters

I am trying to create a class that doesn't re-create an object with the same input parameters. When I try to instantiate a class with the same parameters that were used to create an already-existing object, I just want my new class to return a pointer to the already-created (expensively-created) object. This is what I have tried so far...

C++ templated class implementation of the multiton pattern

I implemented the multiton pattern using a templated class in C++. #ifndef MULTITON_H #define MULTITON_H #include <map> template <typename Key, typename T> class Multiton { public: static void destroy() { for (typename std::map<Key, T*>::iterator it = instances.begin(); it != instances.end(); ++it) { de...

Elegant and 'correct' multiton implementation in Objective C?

Would you call this implementation of a multiton in objective-c 'elegant'? I have programmatically 'disallowed' use of alloc and allocWithZone: because the decision to allocate or not allocate memory needs to be done based on a key. I know for sure that I need to work with only two instances, so I'm using 'switch-case' instead of a map....

Multiple instances of views in PureMVC: Am I doing this right?

What I'm doing NOW: Often multiple instances of the view component would be used in multiple places in an application. Each time I do this, I register the same mediator with a different name. When a notification is dispatched, I attach the name of the mediator to the body of the notification, like so: var obj:Object = new Object(); ...