I am using list~>cells ~>name to get the cell list.This cell list gives the whole list of cells coming from one library. I would like to exclude few cells coming from category in this library.How to get the cell list with specific categories or by excluding specific category cells.
You'll need to use the ddCat* functions - for example, ddCatOpen or ddCatFindCat, then ddCatGetCatMembers, and ddCatClose to close it.
Hello Andrew , Thanks for the reply. I have two list
first , List1=lib ~>cells~>name
second, coming from the category which i would like to exclude List2=mapcar('car ddCatGetCatMembers( catId) )
I have already tried using remd to exclude List2 from List1. I am not sure if it is the right approach to do it.
The simple solution would be to do:
List3=setof(cell List1 !member(cell List2))
There's a potential risk of performance if the number of cells in List2 is very large. If it is, you could do:
catMembers=makeTable('catMembers nil)foreach(cell List2 catMembers[cell]=t)List3=setof(cell List1 !catMembers[cell])
Normally when I want to know the differences between two lists, I use something similar to the first setof() line. I do this for long lists (thousands of cells, and also disembodied property lists) as well. What kind of performance risk are you talking about? It might just take a fraction of a second longer, or is it about memory usage?
I have implemented your second solution at one location and, of course, it works as advertised.
Thanks in advance.
The main issue is that this potentially takes M*N list cell hops (M is the length of the list in the setoff, N is the length of the list that you are checking membership of). If N is long, that's potentially a lot of sequential list cell accesses. If you use an association table instead, the key is hashed which reduces the searching significantly and the cost is closer to kM (where k is a constant).
Essentially this is trying to avoid O(N^2) problems - but this won't be apparent unless N is very big. I did a test with both N and M around 45,000 where I carefully picked that all entries in the setof list are not in the other list, and it took 24 seconds. With the table approach is was less than 1 second (a lot less than 1 second).
Thanks for your detailed explanation.
In the case where either M or N is the largest, it is not even close to the 45000 you've tested, so that's probably the reason I haven't run into long waiting times. As a test I modified the code for that particular instance to have your suggested implementation (with a table) and I saw a modest improvement. I'll definitely use this in the future, even if it wouldn't yield any significant improvement, just as a matter of writing efficient code.