Created
January 16, 2018 03:17
-
-
Save zabirauf/1f03cabc9150e5c817e75803066baf22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code for StringToUintMap.sol | |
pragma solidity ^0.4.15; | |
library StringToUintMap { | |
struct Data { | |
mapping (string => uint8) map; | |
} | |
function insert( | |
Data storage self, | |
string key, | |
uint8 value) public returns (bool updated) | |
{ | |
require(value > 0); | |
updated = self.map[key] != 0; | |
self.map[key] = value; | |
} | |
function get(Data storage self, string key) public returns (uint8) { | |
return self.map[key]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment