So I have some massive calculations to do while looking into Component Repositories. I am trying tor work out the total amount of possible solutions that a OSGi Bundle can have in a repository, currently testing OSGi Bundle Repository. The maximum number of solutions a query could have is the numbeof depended on bundles (D(b)) (2^D(b))-1. This is pretty big, if you have 10 you could have 1023 combinations installed in OSGI, and this is a small number, when it gets into the hundred I worry.
So I have to query over a large space. I was using linkedLists and ArrayLists till I discovered the HashSet. Unbelievable the LinkedList's removeAll function is O(n^2) why is this, because for every item, it must check contains, and it checks contains by going through each element, this is O(n) so O(n) * n ... HashSet is O(1), it is a lockup.
It changed my running time on small sets from 30 seconds to 3. I love HashSets
0 comments:
Post a Comment