SalesforceのmapクラスのkeySetメソッドについて共有します。
対応付けのすべてのキーを含むセットを返します。
Map<String, String> colorCodes = new Map<String, String>();
colorCodes.put('Red', 'FF0000');
colorCodes.put('Blue', '0000A0');
Set <String> colorSet = new Set<String>();
colorSet = colorCodes.keySet();
System.debug('colorSet:'+colorSet);
結果
colorSet:{Blue, Red}