tendermint/libs/common
Dev Ojha c648c93807 Fix random distribution in bitArray.PickRandom (#2534)
* Fix random distribution in bitArray.PickRandom

Previously it was very biased. 63 "_" followed by a single "x" had
much greater odds of being chosen. Additionally, the last element was
skewed. This fixes that by first preproccessing the set of all true
indices, and then randomly selecting a single element from there.

This commit also makes the code here significantly simpler, and
improves test cases.

* unlock mtx right after we select true indices
2018-10-05 11:00:50 +04:00
..
LICENSE mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
async.go make linter happy 2018-07-02 12:06:43 -04:00
async_test.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
bit_array.go Fix random distribution in bitArray.PickRandom (#2534) 2018-10-05 11:00:50 +04:00
bit_array_test.go Fix random distribution in bitArray.PickRandom (#2534) 2018-10-05 11:00:50 +04:00
bytes.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
bytes_test.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
byteslice.go common: Delete unused functions (#2452) 2018-09-20 11:12:42 +02:00
cmap.go cmap: Remove defers (#2210) 2018-08-14 18:59:04 +04:00
cmap_test.go cmap: Remove defers (#2210) 2018-08-14 18:59:04 +04:00
colors.go libs: Remove usage of custom Fmt, in favor of fmt.Sprintf (#2199) 2018-08-10 09:25:57 +04:00
date.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
date_test.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
errors.go libs: Remove usage of custom Fmt, in favor of fmt.Sprintf (#2199) 2018-08-10 09:25:57 +04:00
errors_test.go make linter happy 2018-07-02 12:06:43 -04:00
heap.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
int.go common: Delete unused functions (#2452) 2018-09-20 11:12:42 +02:00
int_test.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
io.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
kvpair.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
math.go Reduce code in common/math (#2274) 2018-08-27 10:43:15 +04:00
net.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
net_test.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
nil.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
os.go libs: Remove usage of custom Fmt, in favor of fmt.Sprintf (#2199) 2018-08-10 09:25:57 +04:00
os_test.go libs/cmn/writefileatomic: Handle file already exists gracefully (#2113) 2018-07-31 19:43:36 +02:00
random.go libs: Remove usage of custom Fmt, in favor of fmt.Sprintf (#2199) 2018-08-10 09:25:57 +04:00
random_test.go common/rand: Remove exponential distribution functions (#1979) 2018-07-16 11:38:04 +04:00
repeat_timer.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
repeat_timer_test.go Switch usage of math/rand to cmn's rand (#1980) 2018-07-16 11:20:37 +04:00
service.go [common] revert started flag when service already stopped (#2326) 2018-09-12 19:07:29 -04:00
service_test.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
string.go common: Delete unused functions (#2452) 2018-09-20 11:12:42 +02:00
string_test.go common: Delete unused functions (#2452) 2018-09-20 11:12:42 +02:00
tempfile.go libs/cmn: Remove Tempfile, Tempdir, switch to ioutil variants (#2114) 2018-07-31 19:43:36 +02:00
tempfile_test.go libs/cmn/writefileatomic: Handle file already exists gracefully (#2113) 2018-07-31 19:43:36 +02:00
throttle_timer.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
throttle_timer_test.go mv tmlibs files to libs dir 2018-07-01 22:36:03 -04:00
types.pb.go General Merkle Follow Up (#2510) 2018-09-28 23:32:13 -04:00
types.proto Add gogo generated tests for pb.go files 2018-07-17 14:56:11 +01:00
typespb_test.go Remove gogoproto from Makefile's TOOLS (#2198) 2018-08-10 09:14:17 +04:00