Skip to content

Commit

Permalink
Remove initialized and init(...) #4
Browse files Browse the repository at this point in the history
  • Loading branch information
bokkypoobah committed Feb 24, 2019
1 parent d1d3649 commit 8133a67
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 176 deletions.
7 changes: 0 additions & 7 deletions contracts/BokkyPoobahsRedBlackTreeLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,12 @@ library BokkyPooBahsRedBlackTreeLibrary {
struct Tree {
uint root;
mapping(uint => Node) nodes;
bool initialised;
}

uint private constant SENTINEL = 0;

event Log(string where, string action, uint key, uint parent, uint left, uint right, bool red);

function init(Tree storage self) internal {
require(!self.initialised);
self.root = SENTINEL;
self.nodes[SENTINEL] = Node(SENTINEL, SENTINEL, SENTINEL, false);
self.initialised = true;
}
function first(Tree storage self) internal view returns (uint _key) {
_key = self.root;
while (_key != SENTINEL && self.nodes[_key].left != SENTINEL) {
Expand Down
1 change: 0 additions & 1 deletion contracts/TestBokkyPoobahsRedBlackTree.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ contract TestBokkyPooBahsRedBlackTree {
event Log(string where, string action, uint key, uint parent, uint left, uint right, bool red);

constructor() public {
tree.init();
}
function root() public view returns (uint _key) {
_key = tree.root;
Expand Down
1 change: 0 additions & 1 deletion contracts/TestBokkyPoobahsRedBlackTreeRaw.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ contract TestBokkyPooBahsRedBlackTreeRaw {
event Log(string where, string action, uint key, uint parent, uint left, uint right, bool red);

constructor() public {
tree.init();
}
function root() public view returns (uint _key) {
_key = tree.root;
Expand Down
8 changes: 0 additions & 8 deletions flattened/TestBokkyPooBahsRedBlackTreeRaw_flattened.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,12 @@ library BokkyPooBahsRedBlackTreeLibrary {
struct Tree {
uint root;
mapping(uint => Node) nodes;
bool initialised;
}

uint private constant SENTINEL = 0;

event Log(string where, string action, uint key, uint parent, uint left, uint right, bool red);

function init(Tree storage self) internal {
require(!self.initialised);
self.root = SENTINEL;
self.nodes[SENTINEL] = Node(SENTINEL, SENTINEL, SENTINEL, false);
self.initialised = true;
}
function first(Tree storage self) internal view returns (uint _key) {
_key = self.root;
while (_key != SENTINEL && self.nodes[_key].left != SENTINEL) {
Expand Down Expand Up @@ -398,7 +391,6 @@ contract TestBokkyPooBahsRedBlackTreeRaw {
event Log(string where, string action, uint key, uint parent, uint left, uint right, bool red);

constructor() public {
tree.init();
}
function root() public view returns (uint _key) {
_key = tree.root;
Expand Down
7 changes: 0 additions & 7 deletions test/BokkyPoobahsRedBlackTreeLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,12 @@ library BokkyPooBahsRedBlackTreeLibrary {
struct Tree {
uint root;
mapping(uint => Node) nodes;
bool initialised;
}

uint private constant SENTINEL = 0;

event Log(string where, string action, uint key, uint parent, uint left, uint right, bool red);

function init(Tree storage self) internal {
require(!self.initialised);
self.root = SENTINEL;
self.nodes[SENTINEL] = Node(SENTINEL, SENTINEL, SENTINEL, false);
self.initialised = true;
}
function first(Tree storage self) internal view returns (uint _key) {
_key = self.root;
while (_key != SENTINEL && self.nodes[_key].left != SENTINEL) {
Expand Down
4 changes: 2 additions & 2 deletions test/TestBokkyPooBahsRedBlackTreeRaw.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test/TestBokkyPoobahsRedBlackTree.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ contract TestBokkyPooBahsRedBlackTree {
event Log(string where, string action, uint key, uint parent, uint left, uint right, bool red);

constructor() public {
tree.init();
}
function root() public view returns (uint _key) {
_key = tree.root;
Expand Down
1 change: 0 additions & 1 deletion test/TestBokkyPoobahsRedBlackTreeRaw.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ contract TestBokkyPooBahsRedBlackTreeRaw {
event Log(string where, string action, uint key, uint parent, uint left, uint right, bool red);

constructor() public {
tree.init();
}
function root() public view returns (uint _key) {
_key = tree.root;
Expand Down
4 changes: 2 additions & 2 deletions test/deploymentData.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8133a67

Please sign in to comment.