```\nfunction remove(Map storage map, address key) internal {\n    if (!map.inserted[key]) {\n        return;\n    }\n\n    delete map.inserted[key];\n    delete map.values[key];\n\n    uint256 index = map.indexOf[key];\n    uint256 lastIndex = map.keys.length - 1;\n    address lastKey = map.keys[lastIndex];\n\n    map.indexOf[lastKey] = index;\n    delete map.indexOf[key];\n\n    map.keys[index] = lastKey;\n    map.keys.pop();\n}\n```\n