HashTable: Added C++11 initializer_list constructor

e.g.
    HashTable<label, string> table1
    {
        {"kjhk", 10},
        {"kjhk2", 12}
    };

    HashTable<label, label, Hash<label>> table2
    {
        {3, 10},
        {5, 12},
        {7, 16}
    };
This commit is contained in:
Henry Weller
2016-08-05 22:30:26 +01:00
parent 2bb52eff6e
commit 076c4c6e82
4 changed files with 63 additions and 52 deletions

View File

@ -49,6 +49,7 @@ SourceFiles
#include "word.H"
#include "Xfer.H"
#include "className.H"
#include <initializer_list>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -62,6 +63,9 @@ template<class T> class UList;
template<class T, class Key, class Hash> class HashTable;
template<class T, class Key, class Hash> class HashPtrTable;
template<class Type1, class Type2>
class Tuple2;
template<class T, class Key, class Hash>
Istream& operator>>(Istream&, HashTable<T, Key, Hash>&);
@ -171,6 +175,7 @@ class HashTable
//- Assign a new hashedEntry to a possibly already existing key
bool set(const Key&, const T& newElmt, bool protect);
public:
// Forward declaration of iterators
@ -207,6 +212,9 @@ public:
//- Construct by transferring the parameter contents
HashTable(const Xfer<HashTable<T, Key, Hash>>&);
//- Construct from an initializer list
HashTable(std::initializer_list<Tuple2<Key, T>> lst);
//- Destructor
~HashTable();