Guest User

Untitled

a guest
Jun 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. // @abi table items i64
  2. struct item {
  3. uint64_t key;
  4. uint64_t numA;
  5. uint64_t numB;
  6. uint64_t numC;
  7. uint64_t numD;
  8.  
  9. auto primary_key() const {return key; }
  10. uint64_t bynuma() const { return numA; }
  11. uint64_t bynumb() const { return numB; }
  12. uint64_t bynumc() const { return numC; }
  13. uint64_t bynumd() const { return numD; }
  14.  
  15. EOSLIB_SERIALIZE (item, (key)(numA)(numB)(numC)(numD));
  16. };
  17.  
  18. typedef eosio::multi_index<N(items), item,
  19. indexed_by< N(numa),
  20. const_mem_fun<item, uint64_t, &item::bynuma>
  21. >,
  22. indexed_by< N(numb),
  23. const_mem_fun<item, uint64_t, &item::bynumb>
  24. >
  25. > item_table;
  26.  
  27. // prints all the items correctly
  28. void scratch::getdefault () {
  29. print ("Items sorted by An");
  30. item_table item_t (_self, _self);
  31. auto item_itr = item_t.begin();
  32.  
  33. while (item_itr != item_t.end()) {
  34. print ( " A=", item_itr->numA, ", B=", item_itr->numB, ", C=", item_itr->numC, ", D=", item_itr->numD, "n");
  35. item_itr++;
  36. }
  37. print ("End of items");
  38. }
  39.  
  40. // does not find any items
  41. void scratch::getnuma ( ) {
  42. print ("Items sorted by An");
  43. item_table item_t (_self, _self);
  44. auto item_index = item_t.get_index< N(numa)>();
  45. auto item_itr = item_index.begin();
  46.  
  47. while (item_itr != item_index.end()) {
  48. print ( " A=", item_itr->numA, ", B=", item_itr->numB, ", C=", item_itr->numC, ", D=", item_itr->numD, "n");
  49. item_itr++;
  50. }
  51. print ("End of items");
  52. }
  53.  
  54. // does not find any items
  55. void scratch::getnumb () {
  56.  
  57. item_table item_t (_self, _self);
  58. auto expidx = item_t.get_index<N(numb)>();
  59.  
  60. print("Items sorted by Bn");
  61. for( const auto& item : expidx ) {
  62. print ( " A=", item.numA, ", B=", item.numB, ", C=", item.numC, ", D=", item.numD, "n");
  63. }
  64. print ("End of items");
  65. }
Add Comment
Please, Sign In to add comment