Library for managing enumerable maps in storage.
error EnumerableMapKeyNotFound()The key does not exist in the enumerable map.
struct Bytes32ToBytes32Map {
EnumerableSetLib.Bytes32Set _keys;
mapping(bytes32 => bytes32) _values;
}An enumerable map of bytes32 to bytes32.
struct Bytes32ToUint256Map {
EnumerableSetLib.Bytes32Set _keys;
mapping(bytes32 => uint256) _values;
}An enumerable map of bytes32 to uint256.
struct Bytes32ToAddressMap {
EnumerableSetLib.Bytes32Set _keys;
mapping(bytes32 => address) _values;
}An enumerable map of bytes32 to address.
struct Uint256ToBytes32Map {
EnumerableSetLib.Uint256Set _keys;
mapping(uint256 => bytes32) _values;
}An enumerable map of uint256 to bytes32.
struct Uint256ToUint256Map {
EnumerableSetLib.Uint256Set _keys;
mapping(uint256 => uint256) _values;
}An enumerable map of uint256 to uint256.
struct Uint256ToAddressMap {
EnumerableSetLib.Uint256Set _keys;
mapping(uint256 => address) _values;
}An enumerable map of uint256 to address.
struct AddressToBytes32Map {
EnumerableSetLib.AddressSet _keys;
mapping(address => bytes32) _values;
}An enumerable map of address to bytes32.
struct AddressToUint256Map {
EnumerableSetLib.AddressSet _keys;
mapping(address => uint256) _values;
}An enumerable map of address to uint256.
struct AddressToAddressMap {
EnumerableSetLib.AddressSet _keys;
mapping(address => address) _values;
}An enumerable map of address to address.
function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value)
internal
returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
function set(
Bytes32ToBytes32Map storage map,
bytes32 key,
bytes32 value,
uint256 cap
) internal returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
Reverts if the map grows bigger than the custom on-the-fly capacity cap.
function remove(Bytes32ToBytes32Map storage map, bytes32 key)
internal
returns (bool)Removes a key-value pair from the map.
Returns true if key was removed from the map, that is if it was present.
function update(
Bytes32ToBytes32Map storage map,
bytes32 key,
bytes32 value,
bool isAdd,
uint256 cap
) internal returns (bool)Shorthand for isAdd ? map.set(key, value, cap) : map.remove(key).
function contains(Bytes32ToBytes32Map storage map, bytes32 key)
internal
view
returns (bool)Returns true if the key is in the map.
function length(Bytes32ToBytes32Map storage map)
internal
view
returns (uint256)Returns the number of key-value pairs in the map.
function at(Bytes32ToBytes32Map storage map, uint256 i)
internal
view
returns (bytes32 key, bytes32 value)Returns the key-value pair at index i. Reverts if i is out-of-bounds.
function tryGet(Bytes32ToBytes32Map storage map, bytes32 key)
internal
view
returns (bool exists, bytes32 value)Tries to return the value associated with the key.
function get(Bytes32ToBytes32Map storage map, bytes32 key)
internal
view
returns (bytes32 value)Returns the value for the key. Reverts if the key is not found.
function keys(Bytes32ToBytes32Map storage map)
internal
view
returns (bytes32[] memory)Returns the keys. May run out-of-gas if the map is too big.
function set(Bytes32ToUint256Map storage map, bytes32 key, uint256 value)
internal
returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
function set(
Bytes32ToUint256Map storage map,
bytes32 key,
uint256 value,
uint256 cap
) internal returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
Reverts if the map grows bigger than the custom on-the-fly capacity cap.
function remove(Bytes32ToUint256Map storage map, bytes32 key)
internal
returns (bool)Removes a key-value pair from the map.
Returns true if key was removed from the map, that is if it was present.
function update(
Bytes32ToUint256Map storage map,
bytes32 key,
uint256 value,
bool isAdd,
uint256 cap
) internal returns (bool)Shorthand for isAdd ? map.set(key, value, cap) : map.remove(key).
function contains(Bytes32ToUint256Map storage map, bytes32 key)
internal
view
returns (bool)Returns true if the key is in the map.
function length(Bytes32ToUint256Map storage map)
internal
view
returns (uint256)Returns the number of key-value pairs in the map.
function at(Bytes32ToUint256Map storage map, uint256 i)
internal
view
returns (bytes32 key, uint256 value)Returns the key-value pair at index i. Reverts if i is out-of-bounds.
function tryGet(Bytes32ToUint256Map storage map, bytes32 key)
internal
view
returns (bool exists, uint256 value)Tries to return the value associated with the key.
function get(Bytes32ToUint256Map storage map, bytes32 key)
internal
view
returns (uint256 value)Returns the value for the key. Reverts if the key is not found.
function keys(Bytes32ToUint256Map storage map)
internal
view
returns (bytes32[] memory)Returns the keys. May run out-of-gas if the map is too big.
function set(Bytes32ToAddressMap storage map, bytes32 key, address value)
internal
returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
function set(
Bytes32ToAddressMap storage map,
bytes32 key,
address value,
uint256 cap
) internal returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
Reverts if the map grows bigger than the custom on-the-fly capacity cap.
function remove(Bytes32ToAddressMap storage map, bytes32 key)
internal
returns (bool)Removes a key-value pair from the map.
Returns true if key was removed from the map, that is if it was present.
function update(
Bytes32ToAddressMap storage map,
bytes32 key,
address value,
bool isAdd,
uint256 cap
) internal returns (bool)Shorthand for isAdd ? map.set(key, value, cap) : map.remove(key).
function contains(Bytes32ToAddressMap storage map, bytes32 key)
internal
view
returns (bool)Returns true if the key is in the map.
function length(Bytes32ToAddressMap storage map)
internal
view
returns (uint256)Returns the number of key-value pairs in the map.
function at(Bytes32ToAddressMap storage map, uint256 i)
internal
view
returns (bytes32 key, address value)Returns the key-value pair at index i. Reverts if i is out-of-bounds.
function tryGet(Bytes32ToAddressMap storage map, bytes32 key)
internal
view
returns (bool exists, address value)Tries to return the value associated with the key.
function get(Bytes32ToAddressMap storage map, bytes32 key)
internal
view
returns (address value)Returns the value for the key. Reverts if the key is not found.
function keys(Bytes32ToAddressMap storage map)
internal
view
returns (bytes32[] memory)Returns the keys. May run out-of-gas if the map is too big.
function set(Uint256ToBytes32Map storage map, uint256 key, bytes32 value)
internal
returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
function set(
Uint256ToBytes32Map storage map,
uint256 key,
bytes32 value,
uint256 cap
) internal returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
Reverts if the map grows bigger than the custom on-the-fly capacity cap.
function remove(Uint256ToBytes32Map storage map, uint256 key)
internal
returns (bool)Removes a key-value pair from the map.
Returns true if key was removed from the map, that is if it was present.
function update(
Uint256ToBytes32Map storage map,
uint256 key,
bytes32 value,
bool isAdd,
uint256 cap
) internal returns (bool)Shorthand for isAdd ? map.set(key, value, cap) : map.remove(key).
function contains(Uint256ToBytes32Map storage map, uint256 key)
internal
view
returns (bool)Returns true if the key is in the map.
function length(Uint256ToBytes32Map storage map)
internal
view
returns (uint256)Returns the number of key-value pairs in the map.
function at(Uint256ToBytes32Map storage map, uint256 i)
internal
view
returns (uint256 key, bytes32 value)Returns the key-value pair at index i. Reverts if i is out-of-bounds.
function tryGet(Uint256ToBytes32Map storage map, uint256 key)
internal
view
returns (bool exists, bytes32 value)Tries to return the value associated with the key.
function get(Uint256ToBytes32Map storage map, uint256 key)
internal
view
returns (bytes32 value)Returns the value for the key. Reverts if the key is not found.
function keys(Uint256ToBytes32Map storage map)
internal
view
returns (uint256[] memory)Returns the keys. May run out-of-gas if the map is too big.
function set(Uint256ToUint256Map storage map, uint256 key, uint256 value)
internal
returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
function set(
Uint256ToUint256Map storage map,
uint256 key,
uint256 value,
uint256 cap
) internal returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
Reverts if the map grows bigger than the custom on-the-fly capacity cap.
function remove(Uint256ToUint256Map storage map, uint256 key)
internal
returns (bool)Removes a key-value pair from the map.
Returns true if key was removed from the map, that is if it was present.
function update(
Uint256ToUint256Map storage map,
uint256 key,
uint256 value,
bool isAdd,
uint256 cap
) internal returns (bool)Shorthand for isAdd ? map.set(key, value, cap) : map.remove(key).
function contains(Uint256ToUint256Map storage map, uint256 key)
internal
view
returns (bool)Returns true if the key is in the map.
function length(Uint256ToUint256Map storage map)
internal
view
returns (uint256)Returns the number of key-value pairs in the map.
function at(Uint256ToUint256Map storage map, uint256 i)
internal
view
returns (uint256 key, uint256 value)Returns the key-value pair at index i. Reverts if i is out-of-bounds.
function tryGet(Uint256ToUint256Map storage map, uint256 key)
internal
view
returns (bool exists, uint256 value)Tries to return the value associated with the key.
function get(Uint256ToUint256Map storage map, uint256 key)
internal
view
returns (uint256 value)Returns the value for the key. Reverts if the key is not found.
function keys(Uint256ToUint256Map storage map)
internal
view
returns (uint256[] memory)Returns the keys. May run out-of-gas if the map is too big.
function set(Uint256ToAddressMap storage map, uint256 key, address value)
internal
returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
function set(
Uint256ToAddressMap storage map,
uint256 key,
address value,
uint256 cap
) internal returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
Reverts if the map grows bigger than the custom on-the-fly capacity cap.
function remove(Uint256ToAddressMap storage map, uint256 key)
internal
returns (bool)Removes a key-value pair from the map.
Returns true if key was removed from the map, that is if it was present.
function update(
Uint256ToAddressMap storage map,
uint256 key,
address value,
bool isAdd,
uint256 cap
) internal returns (bool)Shorthand for isAdd ? map.set(key, value, cap) : map.remove(key).
function contains(Uint256ToAddressMap storage map, uint256 key)
internal
view
returns (bool)Returns true if the key is in the map.
function length(Uint256ToAddressMap storage map)
internal
view
returns (uint256)Returns the number of key-value pairs in the map.
function at(Uint256ToAddressMap storage map, uint256 i)
internal
view
returns (uint256 key, address value)Returns the key-value pair at index i. Reverts if i is out-of-bounds.
function tryGet(Uint256ToAddressMap storage map, uint256 key)
internal
view
returns (bool exists, address value)Tries to return the value associated with the key.
function get(Uint256ToAddressMap storage map, uint256 key)
internal
view
returns (address value)Returns the value for the key. Reverts if the key is not found.
function keys(Uint256ToAddressMap storage map)
internal
view
returns (uint256[] memory)Returns the keys. May run out-of-gas if the map is too big.
function set(AddressToBytes32Map storage map, address key, bytes32 value)
internal
returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
function set(
AddressToBytes32Map storage map,
address key,
bytes32 value,
uint256 cap
) internal returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
Reverts if the map grows bigger than the custom on-the-fly capacity cap.
function remove(AddressToBytes32Map storage map, address key)
internal
returns (bool)Removes a key-value pair from the map.
Returns true if key was removed from the map, that is if it was present.
function update(
AddressToBytes32Map storage map,
address key,
bytes32 value,
bool isAdd,
uint256 cap
) internal returns (bool)Shorthand for isAdd ? map.set(key, value, cap) : map.remove(key).
function contains(AddressToBytes32Map storage map, address key)
internal
view
returns (bool)Returns true if the key is in the map.
function length(AddressToBytes32Map storage map)
internal
view
returns (uint256)Returns the number of key-value pairs in the map.
function at(AddressToBytes32Map storage map, uint256 i)
internal
view
returns (address key, bytes32 value)Returns the key-value pair at index i. Reverts if i is out-of-bounds.
function tryGet(AddressToBytes32Map storage map, address key)
internal
view
returns (bool exists, bytes32 value)Tries to return the value associated with the key.
function get(AddressToBytes32Map storage map, address key)
internal
view
returns (bytes32 value)Returns the value for the key. Reverts if the key is not found.
function keys(AddressToBytes32Map storage map)
internal
view
returns (address[] memory)Returns the keys. May run out-of-gas if the map is too big.
function set(AddressToUint256Map storage map, address key, uint256 value)
internal
returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
function set(
AddressToUint256Map storage map,
address key,
uint256 value,
uint256 cap
) internal returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
Reverts if the map grows bigger than the custom on-the-fly capacity cap.
function remove(AddressToUint256Map storage map, address key)
internal
returns (bool)Removes a key-value pair from the map.
Returns true if key was removed from the map, that is if it was present.
function update(
AddressToUint256Map storage map,
address key,
uint256 value,
bool isAdd,
uint256 cap
) internal returns (bool)Shorthand for isAdd ? map.set(key, value, cap) : map.remove(key).
function contains(AddressToUint256Map storage map, address key)
internal
view
returns (bool)Returns true if the key is in the map.
function length(AddressToUint256Map storage map)
internal
view
returns (uint256)Returns the number of key-value pairs in the map.
function at(AddressToUint256Map storage map, uint256 i)
internal
view
returns (address key, uint256 value)Returns the key-value pair at index i. Reverts if i is out-of-bounds.
function tryGet(AddressToUint256Map storage map, address key)
internal
view
returns (bool exists, uint256 value)Tries to return the value associated with the key.
function get(AddressToUint256Map storage map, address key)
internal
view
returns (uint256 value)Returns the value for the key. Reverts if the key is not found.
function keys(AddressToUint256Map storage map)
internal
view
returns (address[] memory)Returns the keys. May run out-of-gas if the map is too big.
function set(AddressToAddressMap storage map, address key, address value)
internal
returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
function set(
AddressToAddressMap storage map,
address key,
address value,
uint256 cap
) internal returns (bool)Adds a key-value pair to the map, or updates the value for an existing key.
Returns true if key was added to the map, that is if it was not already present.
Reverts if the map grows bigger than the custom on-the-fly capacity cap.
function remove(AddressToAddressMap storage map, address key)
internal
returns (bool)Removes a key-value pair from the map.
Returns true if key was removed from the map, that is if it was present.
function update(
AddressToAddressMap storage map,
address key,
address value,
bool isAdd,
uint256 cap
) internal returns (bool)Shorthand for isAdd ? map.set(key, value, cap) : map.remove(key).
function contains(AddressToAddressMap storage map, address key)
internal
view
returns (bool)Returns true if the key is in the map.
function length(AddressToAddressMap storage map)
internal
view
returns (uint256)Returns the number of key-value pairs in the map.
function at(AddressToAddressMap storage map, uint256 i)
internal
view
returns (address key, address value)Returns the key-value pair at index i. Reverts if i is out-of-bounds.
function tryGet(AddressToAddressMap storage map, address key)
internal
view
returns (bool exists, address value)Tries to return the value associated with the key.
function get(AddressToAddressMap storage map, address key)
internal
view
returns (address value)Returns the value for the key. Reverts if the key is not found.
function keys(AddressToAddressMap storage map)
internal
view
returns (address[] memory)Returns the keys. May run out-of-gas if the map is too big.