1 // hash_set stl/clr header
2 #ifndef _CLI_HASH_SET_
3  #define _CLI_HASH_SET_
4 #include <cliext/xhash>
5
6 namespace cliext {
7     namespace impl {
8 //
9 // TEMPLATE CLASS hash_set_traits
10 //
11 template<typename _Key_t,    // key type
12     bool _Mflag>            // true if multiple equivalent keys are permitted
13     ref class hash_set_traits
14     {    // traits required to make hash table behave like a set
15 public:
16     typedef hash_set_traits<_Key_t, _Mflag> _Mytype_t;
17
18     typedef _Key_t key_type;
19     typedef _Key_t value_type;
20     typedef _STLCLR BinaryDelegate<key_type, key_type, bool>
21         key_compare;
22     typedef key_compare value_compare;
23     typedef _STLCLR UnaryDelegate<key_type, int> hasher;
24
25     typedef _Key_t generic_key;
26
27     hash_set_traits()
28         :    comp(gcnew key_compare(&_Hash_key_compare)),
29             hash_fun(gcnew hasher(&_Hasher)),
30             _Multi(_Mflag)
31         {    // construct with default comparator and hash function
32         }
33
34     hash_set_traits(key_compare^ _Pred)
35         :    comp(_Pred),
36             hash_fun(gcnew hasher(&_Hasher)),
37             _Multi(_Mflag)
38         {    // construct with specified comparator and default hash function
39         }
40
41     hash_set_traits(key_compare^ _Pred, hasher^ _Hashfn)
42         :    comp(_Pred), hash_fun(_Hashfn),
43             _Multi(_Mflag)
44         {    // construct with specified comparator and default hash function
45         }
46
47     key_compare^ key_comp()
48         {    // return object for comparing keys
49         return (comp);
50         }
51
52     value_compare^ value_comp()
53         {    // return object for comparing keys
Lines 54 ... 1214 are skipped.
1215         }
1216
1217     hash_multiset(_Myenum_it^ _Right,
1218         key_compare^ _Pred)
1219         :    _Mybase_t(_Pred)
1220         {    // construct hash_multiset from enumeration, comparator
1221         for each (value_type _Val in _Right)
1222             insert(_Val);
1223         }
1224
1225     hash_multiset(_Myenum_it^ _Right,
1226         key_compare^ _Pred, hasher^ _Hasher)
1227         :    _Mybase_t(_Pred, _Hasher)
1228         {    // construct map from enumeration, compare and hash
1229         for each (value_type _Val in _Right)
1230             insert(_Val);
1231         }
1232
1233     // mutators
1234     void swap(hash_multiset% _Right)
1235         {    // exchange contents with _Right
1236         _Mybase_t::swap(_Right);
1237         }
1238
1239     // interfaces
1240 public:
1241     virtual System::Object^ Clone() override
1242         {    // clone the vector
1243         return (gcnew _Mytype_t(*this));
1244         }
1245     };
1246
1247 //
1248 // TEMPLATE FUNCTION swap
1249 //
1250 template<typename _Key_t> inline
1251     void swap(cliext::hash_multiset<_Key_t>% _Left,
1252         cliext::hash_multiset<_Key_t>% _Right)
1253     {    // swap two hash_multisets
1254     _Left.swap(_Right);
1255     }
1256 }    // namespace cliext
1257 #endif // _CLI_HASH_SET_
1258
1259 /*
1260  * Copyright (c) 2004-2007 by Dinkumware, Ltd.  ALL RIGHTS RESERVED.
1261  * Consult your license regarding permissions and restrictions.
1262 V5.03:0009 */
1263