Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if( 0 == ids.size() ) { return digest_type(); }
- while( ids.size() > 1 ) {
- if( ids.size() % 2 )
- ids.push_back(ids.back());
- for (size_t i = 0; i < ids.size() / 2; i++) {
- ids[i] = digest_type::hash(make_canonical_pair(ids[2 * i], ids[(2 * i) + 1]));
- }
- ids.resize(ids.size() / 2);
- }
- if( ids.size() % 2 ) // If the remainder of size() / 2 is not 0
- ids.push_back(ids.back()); //Push back a duplicate of the last element
- return ids.front(); // Returns the only element left in the vector
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement