Re: php-src /ext/standard array.c php_array.h /ext/unicode collator.c config.m4 config.w32 php_unicode.h unicode.c

[email protected] ("l0t3k")
Newsgroups php.i18n,php.internals
Message-ID <[email protected]>
Derick,
  i know this is the initial dump, but have a look also here :

http://icu.sourceforge.net/userguide/Collate_ServiceArchitecture.html#Sort_Key

For small lists the current implementation is OK, but after a threshold, 
sort keys are better performance-wise.

Here's an implementation of mine (untested, unfortunately) which attempts to 
use sort-keys as well as accomodating iterators (search for "sort").
Never mind the use of the C++ API, the concept is the same.

http://cvs.iworks.at/co.php/php-i18n/collator.cpp?r=1.3

I actually have a different implementation (strictly C) which switches 
between ucol_compare and sort-key generation after a threshold,
but i havent had time to work on it.

l0t3k

""Derick Rethans"" <[email protected]> wrote in message 
news:cvsderick1143371184@cvsserver...
> derick Sun Mar 26 11:06:24 2006 UTC
>
>  Added files:
>    /php-src/ext/unicode collator.c
>
>  Modified files:
>    /php-src/ext/standard array.c php_array.h
>    /php-src/ext/unicode config.m4 config.w32 php_unicode.h unicode.c
>  Log:
>  - Implemented basic collation support. For some reason "new Collator" 
> gives segfaults when the object's collation resource is used.
>  - The following example shows what is implemented:
>
>  <?php
>  $orig = $strings = array(
>      'côte',
>      'cote',
>      'côté',
>      'coté',
>      'fluÃYe',
>      'flüÃYe',
>  );
>
>  echo "German phonebook:\n";
>  $c = collator_create( "de@collation=phonebook" );
>  foreach($c->sort($strings) as $string) {
>      echo $string, "\n";
>  }
>  echo $c->getAttribute(Collator::FRENCH_COLLATION) == Collator::ON
>      ? "With" : "Without", " french accent sorting order\n";
>
>  echo "\nFrench with options:\n";
>  $c = collator_create( "fr" );
>  $c->setAttribute(Collator::CASE_FIRST, Collator::UPPER_FIRST);
>  $c->setAttribute(Collator::CASE_LEVEL, Collator::ON);
>  $c->setStrength(Collator::SECONDARY);
>  foreach($c->sort($strings) as $string) {
>      echo $string, "\n";
>  }
>  echo $c->getAttribute(Collator::FRENCH_COLLATION) == Collator::ON
>      ? "With" : "Without", " french accent sorting order\n";
>  ?>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.