Skip to content

Commit

Permalink
Remove inserted and removed counters #2
Browse files Browse the repository at this point in the history
  • Loading branch information
bokkypoobah committed Feb 24, 2019
1 parent 0649b3b commit d540dfc
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 329 deletions.
7 changes: 0 additions & 7 deletions contracts/BokkyPoobahsRedBlackTreeLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ library BokkyPooBahsRedBlackTreeLibrary {
uint root;
mapping(uint => Node) nodes;
bool initialised;
uint inserted;
uint removed;
}

uint private constant SENTINEL = 0;
Expand All @@ -39,9 +37,6 @@ library BokkyPooBahsRedBlackTreeLibrary {
self.nodes[SENTINEL] = Node(SENTINEL, SENTINEL, SENTINEL, false);
self.initialised = true;
}
function count(Tree storage self) internal view returns (uint _count) {
return self.inserted >= self.removed ? self.inserted - self.removed: 0;
}
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 @@ -175,7 +170,6 @@ library BokkyPooBahsRedBlackTreeLibrary {
self.nodes[y].right = z;
}
insertFixup(self, z);
self.inserted++;
}
function remove(Tree storage self, uint z) internal {
require(z != SENTINEL);
Expand Down Expand Up @@ -230,7 +224,6 @@ library BokkyPooBahsRedBlackTreeLibrary {
delete self.nodes[SENTINEL];
}
delete self.nodes[y];
self.removed++;
}

function treeMinimum(Tree storage self, uint key) private view returns (uint) {
Expand Down
9 changes: 0 additions & 9 deletions contracts/TestBokkyPoobahsRedBlackTree.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ contract TestBokkyPooBahsRedBlackTree {
function root() public view returns (uint _key) {
_key = tree.root;
}
function inserted() public view returns (uint _inserted) {
_inserted = tree.inserted;
}
function removed() public view returns (uint _removed) {
_removed = tree.removed;
}
function count() public view returns (uint _count) {
_count = tree.count();
}
function first() public view returns (uint _key) {
_key = tree.first();
}
Expand Down
9 changes: 0 additions & 9 deletions contracts/TestBokkyPoobahsRedBlackTreeRaw.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ contract TestBokkyPooBahsRedBlackTreeRaw {
function root() public view returns (uint _key) {
_key = tree.root;
}
function inserted() public view returns (uint _inserted) {
_inserted = tree.inserted;
}
function removed() public view returns (uint _removed) {
_removed = tree.removed;
}
function count() public view returns (uint _count) {
_count = tree.count();
}
function first() public view returns (uint _key) {
_key = tree.first();
}
Expand Down
16 changes: 0 additions & 16 deletions flattened/TestBokkyPooBahsRedBlackTreeRaw_flattened.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ library BokkyPooBahsRedBlackTreeLibrary {
uint root;
mapping(uint => Node) nodes;
bool initialised;
uint inserted;
uint removed;
}

uint private constant SENTINEL = 0;
Expand All @@ -40,9 +38,6 @@ library BokkyPooBahsRedBlackTreeLibrary {
self.nodes[SENTINEL] = Node(SENTINEL, SENTINEL, SENTINEL, false);
self.initialised = true;
}
function count(Tree storage self) internal view returns (uint _count) {
return self.inserted >= self.removed ? self.inserted - self.removed: 0;
}
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 @@ -176,7 +171,6 @@ library BokkyPooBahsRedBlackTreeLibrary {
self.nodes[y].right = z;
}
insertFixup(self, z);
self.inserted++;
}
function remove(Tree storage self, uint z) internal {
require(z != SENTINEL);
Expand Down Expand Up @@ -231,7 +225,6 @@ library BokkyPooBahsRedBlackTreeLibrary {
delete self.nodes[SENTINEL];
}
delete self.nodes[y];
self.removed++;
}

function treeMinimum(Tree storage self, uint key) private view returns (uint) {
Expand Down Expand Up @@ -431,15 +424,6 @@ contract TestBokkyPooBahsRedBlackTreeRaw {
function root() public view returns (uint _key) {
_key = tree.root;
}
function inserted() public view returns (uint _inserted) {
_inserted = tree.inserted;
}
function removed() public view returns (uint _removed) {
_removed = tree.removed;
}
function count() public view returns (uint _count) {
_count = tree.count();
}
function first() public view returns (uint _key) {
_key = tree.first();
}
Expand Down
7 changes: 0 additions & 7 deletions test/BokkyPoobahsRedBlackTreeLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ library BokkyPooBahsRedBlackTreeLibrary {
uint root;
mapping(uint => Node) nodes;
bool initialised;
uint inserted;
uint removed;
}

uint private constant SENTINEL = 0;
Expand All @@ -39,9 +37,6 @@ library BokkyPooBahsRedBlackTreeLibrary {
self.nodes[SENTINEL] = Node(SENTINEL, SENTINEL, SENTINEL, false);
self.initialised = true;
}
function count(Tree storage self) internal view returns (uint _count) {
return self.inserted >= self.removed ? self.inserted - self.removed: 0;
}
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 @@ -175,7 +170,6 @@ library BokkyPooBahsRedBlackTreeLibrary {
self.nodes[y].right = z;
}
insertFixup(self, z);
self.inserted++;
}
function remove(Tree storage self, uint z) internal {
require(z != SENTINEL);
Expand Down Expand Up @@ -230,7 +224,6 @@ library BokkyPooBahsRedBlackTreeLibrary {
delete self.nodes[SENTINEL];
}
delete self.nodes[y];
self.removed++;
}

function treeMinimum(Tree storage self, uint key) private view returns (uint) {
Expand Down
6 changes: 3 additions & 3 deletions test/TestBokkyPooBahsRedBlackTreeRaw.js

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions test/TestBokkyPoobahsRedBlackTree.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ contract TestBokkyPooBahsRedBlackTree {
function root() public view returns (uint _key) {
_key = tree.root;
}
function inserted() public view returns (uint _inserted) {
_inserted = tree.inserted;
}
function removed() public view returns (uint _removed) {
_removed = tree.removed;
}
function count() public view returns (uint _count) {
_count = tree.count();
}
function first() public view returns (uint _key) {
_key = tree.first();
}
Expand Down
9 changes: 0 additions & 9 deletions test/TestBokkyPoobahsRedBlackTreeRaw.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ contract TestBokkyPooBahsRedBlackTreeRaw {
function root() public view returns (uint _key) {
_key = tree.root;
}
function inserted() public view returns (uint _inserted) {
_inserted = tree.inserted;
}
function removed() public view returns (uint _removed) {
_removed = tree.removed;
}
function count() public view returns (uint _count) {
_count = tree.count();
}
function first() public view returns (uint _key) {
_key = tree.first();
}
Expand Down
6 changes: 3 additions & 3 deletions test/deploymentData.js

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

3 changes: 0 additions & 3 deletions test/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,6 @@ function printTestRedBlackTreeContractDetails() {
console.log("RESULT: testRedBlackTree.root=" + contract.root());
console.log("RESULT: testRedBlackTree.first=" + contract.first());
console.log("RESULT: testRedBlackTree.last=" + contract.last());
console.log("RESULT: testRedBlackTree.inserted=" + contract.inserted());
console.log("RESULT: testRedBlackTree.removed=" + contract.removed());
console.log("RESULT: testRedBlackTree.count=" + contract.count());

var latestBlock = eth.blockNumber;
var i;
Expand Down
Loading

0 comments on commit d540dfc

Please sign in to comment.