xsl-list
[Top] [All Lists]

Re: [xsl] HST's answers Re: [xsl] Efficient way to check sequence membership -

2011-03-03 01:50:53
On Thu, 03 Mar 2011 00:06:43 +0000
Michael Kay <mike(_at_)saxonica(_dot_)com> wrote:

On 02/03/2011 22:00, Henry S. Thompson wrote:
I've thought of five ways to do this:

  1) tokenise and use "some ...", as in the previous message;
  2) Add '|' at the beginning of both $stopPat and the word to be
     checked, and use contains;
  3) Put a sequence of elements with a 'w' attribute whose value is
a stop in $stops, then do boolean($stops/*[@w=$w]);
  4) As above, but then define an appropriate key and use
      boolean($stops/key('stop',$w));
  5) Build a regexp and use match:
      concat('^(',$stopPat,')$')

Your results don't surprise me. For all except (4), the naive 
implementation is O(n) whereas for (4) it is O(n log n). Now we don't 
know what n is, but if it's large enough then O(n log n) will always 
win. The fact that the different O(n) solutions have different 
multiplying factors is always worth remembering, of course.


Does xslt version next have the member() function Mike?
All these node functions, member seems a fairly obvious one?



-- 

regards 

-- 
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>