Merge branch 'master' into solc-0.7
This commit is contained in:
@ -23,8 +23,8 @@ pragma solidity ^0.7.0;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
|
||||
* (`UintSet`) are supported.
|
||||
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
|
||||
* and `uint256` (`UintSet`) are supported.
|
||||
*/
|
||||
library EnumerableSet {
|
||||
// To implement this library for multiple types with as little code
|
||||
@ -132,6 +132,60 @@ library EnumerableSet {
|
||||
return set._values[index];
|
||||
}
|
||||
|
||||
// Bytes32Set
|
||||
|
||||
struct Bytes32Set {
|
||||
Set _inner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Add a value to a set. O(1).
|
||||
*
|
||||
* Returns true if the value was added to the set, that is if it was not
|
||||
* already present.
|
||||
*/
|
||||
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
|
||||
return _add(set._inner, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Removes a value from a set. O(1).
|
||||
*
|
||||
* Returns true if the value was removed from the set, that is if it was
|
||||
* present.
|
||||
*/
|
||||
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
|
||||
return _remove(set._inner, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns true if the value is in the set. O(1).
|
||||
*/
|
||||
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
|
||||
return _contains(set._inner, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the number of values in the set. O(1).
|
||||
*/
|
||||
function length(Bytes32Set storage set) internal view returns (uint256) {
|
||||
return _length(set._inner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the value stored at position `index` in the set. O(1).
|
||||
*
|
||||
* Note that there are no guarantees on the ordering of values inside the
|
||||
* array, and it may change when more values are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
|
||||
return _at(set._inner, index);
|
||||
}
|
||||
|
||||
// AddressSet
|
||||
|
||||
struct AddressSet {
|
||||
|
||||
Reference in New Issue
Block a user