Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. pragma solidity ^0.4.0;
  2.  
  3. import "github.com/20Scoops-CNX/solidity-utils/lib/ListInteger.sol";
  4.  
  5. import "github.com/20Scoops-CNX/solidity-utils/lib/Strings.sol";
  6.  
  7. import "github.com/20Scoops-CNX/solidity-utils/lib/Integers.sol";
  8.  
  9. contract ExampleContract {
  10. using ListInteger for *;
  11. using Strings for string;
  12. using Integers for uint;
  13.  
  14. uint[] public items;
  15.  
  16. function exist(uint[] items, uint value) public returns (bool) {
  17. uint i = 0;
  18. while (i<items.getSize() && items[i] != value) {
  19. i++;
  20. }
  21.  
  22. if(i>=items.getSize())
  23. return false;
  24. else if( items[i] == value)
  25. return true;
  26.  
  27. }
  28.  
  29. function example(uint c) public returns (uint, uint) {
  30. uint size1 = items.getSize();
  31. if(exist(items,c)){
  32. items.removeByValue(c);
  33. }
  34. uint size2 = items.getSize();
  35. return (size1,size2);
  36. }
  37.  
  38. function example1() public {
  39. items.add(1);
  40. items.add(2);
  41. items.add(4);
  42. items.add(3);
  43. // uint index = items.find(9911);
  44. // return index;
  45. }
  46.  
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement