Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. if( 0 == ids.size() ) { return digest_type(); }
  2.  
  3. while( ids.size() > 1 ) {
  4. if( ids.size() % 2 )
  5. ids.push_back(ids.back());
  6.  
  7. for (size_t i = 0; i < ids.size() / 2; i++) {
  8. ids[i] = digest_type::hash(make_canonical_pair(ids[2 * i], ids[(2 * i) + 1]));
  9. }
  10.  
  11. ids.resize(ids.size() / 2);
  12. }
  13.  
  14. if( ids.size() % 2 ) // If the remainder of size() / 2 is not 0
  15. ids.push_back(ids.back()); //Push back a duplicate of the last element
  16.  
  17. return ids.front(); // Returns the only element left in the vector
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement