Created
November 2, 2018 14:29
-
-
Save stephenh/87f940a1f1356f5ab9f4a8579c567443 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
role1 = { name, perms: [p1, p2, p3] } | |
role2 = { name, perms: [p3, p4] } | |
roles = [role1, role2, ...] | |
# put lists in sorted sort | |
# O(N_roles * N_permissions log N_permissions) | |
roles.forEach { sortInPlace(_.perms) } | |
# compare each role to the other, N^2 = 16m comparison | |
# perms overlap is O(N_perms) = O(300) | |
# 16m * 300 == still doabled | |
roles.each { r1 => | |
roles.each { r2 => | |
intersect(r1.perms, r2.perms) | |
} | |
} | |
intersect(l1, l2) { | |
// https://www.geeksforgeeks.org/intersection-of-two-sorted-linked-lists/ | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment