I have an existing (java) application that models an order book, as it stands each order is visible to every other. There is now a requirement to put (what is effectively) a per order ACL in place.
An example to illustrate, lets say I have access groups [V-Z] and orders [A-F]
A B C D E F
V 1 0 0 1 1 0
W 0 1 1 0 0 1
X 0 0 0 0 1 1
Y 1 1 0 0 0 1
Z 0 1 0 1 0 0
A new order comes in that specifies visibility as W & Y. What would be a fast way to return the set of values that can be seen by the incoming order?
One implementation that has been suggested is to represent each row as a BitSet and do W | Y though I wonder what will happen to performance as the size of the matrix increases.
A nice to have but not essential feature is to allow for a parent-child relationship on one dimension like
A B C D E F
V 1 0 0 1 1 0
W 0 1 1 0 0 1
X-1 0 0 0 0 1 1
X-2 1 0 0 0 1 1
X-3 0 1 0 0 1 1
Y 1 1 0 0 0 1
Z 0 1 0 1 0 0
It would be ideal if it were similarly efficient to retrieve "W | X" as "W | X-1"
Any hints in the direction of an algorithm and/or appropriate data structure much appreciated.