2011/9/13 Clifford Yapp <cliffy...@gmail.com>:
>
>
> On Tue, Sep 13, 2011 at 1:58 PM, David Cole <david.c...@kitware.com> wrote:
>>
>> On Tue, Sep 13, 2011 at 1:39 PM, Alexander Neundorf
>> <a.neundorf-w...@gmx.net> wrote:
>> > On Tuesday, September 13, 2011 05:07:00 AM Clifford Yapp wrote:
>> >> I am trying to compare two large lists of file paths (about 14,000
>> >> lines
>> >> each) to identify which entries in each list are missing from the
>> >> other,
>> >> and while I can get CMake to do it I must be doing it the wrong way
>> >> because the results are hideously slow.
>> >>
>> >> I currently generate two files with the paths and then read them in as
>> >> lists, using LIST() commands to peform STREQUAL tests.  I was hoping to
>> >
>> > How do you do that ?
>> > Do you iterate over one list using foreach() and then list(FIND) to
>> > check
>> > whether it exists in the other list ?
>
> I tried a couple of ways, most of them variations on that theme (BUILD_FILES
> and SVN_FILES are two manifest lists, and I need items from each list that
> are not in the other list)
>
> FOREACH(ITEM ${BUILD_FILES})
>      LIST(FIND ${ITEM} SVN_FILES POS)
>      IF(NOT POS STREQUAL "-1")
>         LIST(REMOVE_ITEM SVN_FILES ${ITEM})
>         LIST(REMOVE_ITEM BUILD_FILES ${ITEM})
>      ENDIF()
> ENDFOREACH()
>
> In essence, the idea is BUILD_FILES will end  up holding items unique to
> BUILD_FILES and SVN_FILES will end up holding items unique to SVN_FILES,
> which are the two pieces of information I'm after.

If  I understand it well you want to compute "symmetric difference".

Assuming BUILD_FILES and SVN_FILES initially contains  the whole list of names.
Then could you try:

set(BUILD_FILES_UNIQUE ${BUILD_FILES})
set(SVN_FILES_UNIQUE ${SVN_FILES})
list(REMOVE_ITEM BUILD_FILES_UNIQUE ${SVN_FILES})
list(REMOVE_ITEM SVN_FILES_UNIQUE ${BUILD_FILES})

I don't know about the performance of this with huge list but after that
BUILD_FILES_UNIQUE and SVN_FILES_UNIQUE should contains what you want.
at least it work on my small (attached) example.


-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
set(LIST1 "a;b;c;g;q")
set(LIST2 "a;b;d;c;h;g")
message("LIST1 = ${LIST1}")
message("LIST2 = ${LIST2}")

set(LIST1_UNIQUE ${LIST1})
set(LIST2_UNIQUE ${LIST2})
message("LIST1_UNIQUE = ${LIST1_UNIQUE}")
message("LIST2_UNIQUE = ${LIST2_UNIQUE}")

list(REMOVE_ITEM LIST1_UNIQUE ${LIST2})
list(REMOVE_ITEM LIST2_UNIQUE ${LIST1})
message("LIST1_UNIQUE = ${LIST1_UNIQUE}")
message("LIST2_UNIQUE = ${LIST2_UNIQUE}")
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to