Example: A customized ContainerFactory using a hashed IdxContainer type

// ... classes as in IndexedDBView example ....
typedef DBView<Example, ParamObjExample> ViewType;
typedef CBFunctor1wRet<const Example *, size_t> IVHash;
typedef CBFunctor2wRet<const Example *, const Example *, bool> IVCompare;
typedef hash_multiset<Example *, IVHash, IVCompare> HashMultisetType; 
typedef DBIndex<ViewType. HashMultisetType, HASH> HashIdxType;

// alternative hashing scheme on exampleStr
size_t my_hash_strings(const Example *pData1)
{
   string str = pData1->GetExampleStr();

   size_t sum = 0;

   // sum all the per character hash values together
   // a character c's hash value = 5*c + 13
   for (size_t i = 0; i < str.length(); i++)
		sum += (5 * str[i] + 13);

   return sum;
}

// "specialized" ContainerFactory() tells IndexedDBView to use a custom
// container for indexing records
// in this case, the container is a hash_multiset which uses an alternative hash
// function for the Primary Index and normal for all other indices

template<> class dtl::ContainerFactory<HashIdxType>
{
public:
	HashMultisetType operator()(HashIdxType *pDBIndex, HASH h) 
	{
		 // for STRING_VALUE's, hash on exampleStr using alternative hash function
	
		 if (pDBIndex->GetName() == "PrimaryIndex")
			return HashMultisetType(MEDIUM_HASH_TABLE, cb_ptr_fun_w_ret(my_hash_strings),
			                        cb_ptr_fun_w_ret(*pDBIndex, &HashIdxType::eq));
		 else // for all other indices use generic hash and comparison
			return HashMultisetType(MEDIUM_HASH_TABLE, cb_ptr_fun_w_ret(*pDBIndex, &HashIdxType::hash),
			                        cb_ptr_fun_w_ret(*pDBIndex, &HashIdxType::eq));
	}
};