mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
14 lines
296 B
Solidity
14 lines
296 B
Solidity
|
library Set {
|
||
|
struct Data { mapping(uint => bool) flags; }
|
||
|
|
||
|
function insert(Data storage self, uint value)
|
||
|
public
|
||
|
returns (bool)
|
||
|
{
|
||
|
if (self.flags[value])
|
||
|
return false; // already there
|
||
|
self.flags[value] = true;
|
||
|
return true;
|
||
|
}
|
||
|
}
|