Effective implementation of algorithms (Master Thesis)
Effective and error-free implementation of algorithms
|
00001 #ifndef H_BALANCED_STRUCTURES_SKIPLIST_SKIPLIST_UTILS 00002 #define H_BALANCED_STRUCTURES_SKIPLIST_SKIPLIST_UTILS 00003 00004 namespace balanced_structures { 00005 namespace skiplist { 00006 00007 namespace node_utils { 00022 template <typename T> 00023 T randomLevel(Rand* rand, int levelup_prob_percent, T max_level) { 00024 Preconditions::check(1 < max_level); 00025 T level = 1; 00026 while ((level < max_level) && 00027 (rand->rand(0, 100) < levelup_prob_percent)) { 00028 level++; 00029 } 00030 return level; 00031 } 00032 00033 } // namespace node_utils 00034 00035 } // namespace skiplist 00036 } // namespace balanced_structures 00037 00038 #endif