[bisq-network/bisq] Dao permute blindvotelist if not majority hash (#2361)

Manfred Karrer notifications at github.com
Sun Feb 3 19:51:07 UTC 2019


ManfredKarrer commented on this pull request.



> +    /**
+     * Returns a list of all possible permutations of a give sorted list ignoring duplicates.
+     * E.g. List [A,B,C] results in this list of permutations: [[A], [B], [A,B], [C], [A,C], [B,C], [A,B,C]]
+     * Number of variations and iterations grows with 2^n - 1 where n is the number of items in the list.
+     * With 20 items we reach about 1 million iterations and it takes about 0.5 sec.
+     * To avoid performance issues we added the maxIterations parameter to stop once the number of iterations has
+     * reached the maxIterations and return in such a case the list of permutations we have been able to create.
+     * Depending on the type of object which is stored in the list the memory usage should to be considered as well for
+     * choosing the right maxIterations value.
+     *
+     * @param list              List from which we create permutations
+     * @param maxIterations     Max. number of iterations including inner iterations
+     * @param <T>               Type of list items
+     * @return List of possible permutations of the original list
+     */
+    public static <T> List<List<T>> findAllPermutations(List<T> list, int maxIterations) {

Yes agree. Not trivial though to optimize it in that direction...

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/2361#discussion_r253316378
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20190203/f3e183fb/attachment.html>


More information about the bisq-github mailing list