Re: FindAll()

new topic     » topic index » view thread      » older message » newer message

>    function find_all(object value, sequence s)
>    object not_value
>    sequence list
>    integer f
>       not_value = not value
>       list = {}
>       f = find(value, s)
>       while f do
>          list = append(list, f) -- append to position list
>          s[f] = not_value       -- so we don't find this one again
>          f = find(value, s)     -- find the next one
>       end while
>       return list
>    end function

off the top of my head, I keep thinking the following would
be far faster, especially considering EU's new optimizations...

function find_all(object value, sequence s)
sequence list   list = {}
   for i = 1 to length(s) do
        if equal(s[i],value) then
           list = append(list,i)
        end if
   end for
   return list
end function

dunno if it's actually faster,
(or if it even works :) )
but IMO it's worth a try, eh?

--Hawke'

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu