Share via


collection_adapter::key_type (STL/CLR)

The type of a dictionary key.

    typedef Key key_type;

Remarks

The type is a synonym for the template parameter Key, in a specialization for IDictionary or IDictionary<Value>; otherwise it is not defined.

Example

// cliext_collection_adapter_key_type.cpp 
// compile with: /clr 
#include <cliext/adapter> 
#include <cliext/map> 
 
typedef cliext::map<wchar_t, int> Mymap; 
typedef cliext::collection_adapter< 
    System::Collections::Generic::IDictionary<wchar_t, int>> Mycoll; 
typedef System::Collections::Generic::KeyValuePair<wchar_t,int> Mypair; 
int main() 
    { 
    Mymap d1; 
    d1.insert(Mymap::make_value(L'a', 1)); 
    d1.insert(Mymap::make_value(L'b', 2)); 
    d1.insert(Mymap::make_value(L'c', 3)); 
    Mycoll c1(%d1); 
 
// display contents " [a 1] [b 2] [c 3]" 
    for each (Mypair elem in c1) 
        { 
        Mycoll::key_type key = elem.Key; 
        Mycoll::mapped_type value = elem.Value; 
        System::Console::Write(" [{0} {1}]", key, value); 
        } 
    System::Console::WriteLine(); 
    return (0); 
    } 
 

[a 1] [b 2] [c 3]

Requirements

Header: <cliext/adapter>

Namespace: cliext

See Also

Reference

collection_adapter (STL/CLR)

collection_adapter::mapped_type (STL/CLR)