Removing elements from a very large list?

Discussion in 'Programming' started by amaze, Oct 17, 2007.

  1. #1
    Hi,

    I have 2 very large lists (one has over 40,000 elements and the other approx 1/2 that). The list elements contain IDs so only 2-6 ints per element.

    I want to remove all the elements of the smaller list from the bigger list so I need to with a third list which will A-B=C (I hope that makes sense).

    This is a one function... What is the best way to do this please?

    Thanks :)
     
    amaze, Oct 17, 2007 IP
  2. Jamie18

    Jamie18 Peon

    Messages:
    201
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you could probably find a faster way to do this but..

    <cfloop list="#a#" index="alist">
    <cfif NOT listfind(b,"#alist#")>
    <cfset temp=listappend(c,"#alist#")>
    </cfif>
    </cfloop>

    for the size of the lists i doubt this is the best method.. but if you're in need of a temporary solution this should work..
     
    Jamie18, Oct 18, 2007 IP
    amaze likes this.
  3. amaze

    amaze Active Member

    Messages:
    594
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    That worked great thanks.. :)
     
    amaze, Oct 18, 2007 IP
  4. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    cfStarlight, Oct 18, 2007 IP