Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // @abi table items i64
- struct item {
- uint64_t key;
- uint64_t numA;
- uint64_t numB;
- uint64_t numC;
- uint64_t numD;
- auto primary_key() const {return key; }
- uint64_t bynuma() const { return numA; }
- uint64_t bynumb() const { return numB; }
- uint64_t bynumc() const { return numC; }
- uint64_t bynumd() const { return numD; }
- EOSLIB_SERIALIZE (item, (key)(numA)(numB)(numC)(numD));
- };
- typedef eosio::multi_index<N(items), item,
- indexed_by< N(numa),
- const_mem_fun<item, uint64_t, &item::bynuma>
- >,
- indexed_by< N(numb),
- const_mem_fun<item, uint64_t, &item::bynumb>
- >
- > item_table;
- // prints all the items correctly
- void scratch::getdefault () {
- print ("Items sorted by An");
- item_table item_t (_self, _self);
- auto item_itr = item_t.begin();
- while (item_itr != item_t.end()) {
- print ( " A=", item_itr->numA, ", B=", item_itr->numB, ", C=", item_itr->numC, ", D=", item_itr->numD, "n");
- item_itr++;
- }
- print ("End of items");
- }
- // does not find any items
- void scratch::getnuma ( ) {
- print ("Items sorted by An");
- item_table item_t (_self, _self);
- auto item_index = item_t.get_index< N(numa)>();
- auto item_itr = item_index.begin();
- while (item_itr != item_index.end()) {
- print ( " A=", item_itr->numA, ", B=", item_itr->numB, ", C=", item_itr->numC, ", D=", item_itr->numD, "n");
- item_itr++;
- }
- print ("End of items");
- }
- // does not find any items
- void scratch::getnumb () {
- item_table item_t (_self, _self);
- auto expidx = item_t.get_index<N(numb)>();
- print("Items sorted by Bn");
- for( const auto& item : expidx ) {
- print ( " A=", item.numA, ", B=", item.numB, ", C=", item.numC, ", D=", item.numD, "n");
- }
- print ("End of items");
- }
Add Comment
Please, Sign In to add comment