Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. self.list_[selfSize] = Interval( { num: e - 1, core: c, next: self.head });
  2. self.list_[selfSize + 1] = Interval( { num: 10, core: 10, next: 10 });
  3.  
  4. //self.list_[2] = Interval( { num: e - 1, core: c, next: self.head });//commented out!!
  5. //self.list_[3] = Interval( { num: 10, core: 10, next: 10 });//commented out!!
  6.  
  7. //self.list_[selfSize] = Interval( { num: e - 1, core: c, next: self.head });//commented out!!
  8. //self.list_[selfSize + 1] = Interval( { num: 10, core: 10, next: 10 });//commented out!!
  9.  
  10. self.list_[2] = Interval( { num: e - 1, core: c, next: self.head });//used GAS = 65220
  11. self.list_[3] = Interval( { num: 10, core: 10, next: 10 });
  12.  
  13. pragma solidity ^0.4.8;
  14. library ReceiptLib {
  15. struct Interval {
  16. uint32 num;
  17. int32 core;
  18. uint32 next;
  19. }
  20.  
  21. struct intervalNode {
  22. uint32 den;
  23. mapping(uint32 => Interval) list_;
  24. uint32 len;
  25. uint32 head;
  26. int32 coreLimit;
  27. }
  28. function constructReceipt(intervalNode storage self){
  29. self.head = 1; //self.listSize - 1;
  30. self.coreLimit = 128;
  31.  
  32. self.list_[0] = Interval( { num: 0, core: 0, next: 0 });
  33. self.list_[1] = Interval( { num: 0, core: 0, next: 0 });
  34. self.len = 2;
  35. }
  36. function number(intervalNode storage self, uint32 s, uint32 e, int32 c){
  37. uint32 selfSize = self.len;
  38. //self.list_[selfSize] = Interval( { num: e - 1, core: c, next: self.head });
  39. //self.list_[selfSize + 1] = Interval( { num: 10, core: 10, next: 10 });
  40.  
  41. self.list_[2] = Interval( { num: e - 1, core: c, next: self.head });
  42. self.list_[3] = Interval( { num: 10, core: 10, next: 10 });
  43. }
  44. }
  45.  
  46. contract Array{
  47. using ReceiptLib for ReceiptLib.intervalNode;
  48. ReceiptLib.intervalNode receiptList;
  49.  
  50. function Array(){
  51. receiptList.constructReceipt();
  52. }
  53. function test(uint32 s, uint32 e, int32 c) {
  54. receiptList.number(s, e, c);
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement