[prev in list] [next in list] [prev in thread] [next in thread] 

List:       icu
Subject:    API addition proposal: CanonicalIterator class
From:       Vladimir Weinstein <weiv () jtcsv ! com>
Date:       2002-09-06 6:20:54
[Download RAW message or body]

Expiration: 09/12/2002

CanonicalIterator class allows iterating over canonicaly equivalent 
sequences to a given sequence. Two sequences are canonically equivalent 
if their NFD forms are the same.

For example, for angstrom sign (U+212B) canonically equivalent sequences 
are U+212B (angstrom sign), U+00C5 (a-ring) and U+0041U+030A 
(a+combining ring).

Canonical iterator is already being used internally for canonical 
closure in collation. We feel that it could also be useful to ICU users.

APIs are proposed for C++ and Java. C API is not planned.

-------------------------------------------------------------------------
C++ API:
class U_I18N_API CanonicalIterator : public UObject {
public:
     /**
      *@param source    string to get results for
      *@param status    Fill-in parameter which receives the status of
      *this operation.
      */
     CanonicalIterator(const UnicodeString &source, UErrorCode &status);

     /** Destructor
      *  Cleans pieces
      */
     ~CanonicalIterator();

     /**
      *@return gets the source:
      *NOTE: it is the NFD form of source
      */
     UnicodeString getSource();

     /**
      * Resets the iterator so that one can start again from the
      * beginning.
      */
     void reset();

     /**
      *@return the next string that is canonically equivalent.
      * A bogus string is returned when the iteration is done.
      */
     UnicodeString next();

     /**
      *@param newSource the source string to iterate against. This
      * allows the same iterator to be used while changing the source
      * string, saving object creation.
      *@param status Fill-in parameter which receives the status of this
      * operation.
      */
     void setSource(const UnicodeString &newSource, UErrorCode &status);
};
-------------------------------------------------------------------------
JAVA API:
public class CanonicalIterator
     /** Constructor. Takes a string to be iterated over.
      *@param source string to get results for
      */
     public CanonicalIterator(String source)

     /**
      *@return gets the source:
      *NOTE: it is the NFD form of the source originally passed in
      */
     public String getSource()

     /**
      * Resets the iterator so that one can start again from the
      * beginning.
      */
     public void reset()

     /**
      *@return the next string that is canonically equivalent. The value 

      *null is returned when the iteration is done.
      *Warning: The strings are not guaranteed to be in any particular 

      *order.
      */
     public String next()
     /**
      *@param set the source string to iterate against. This allows the
      *same iterator to be used while changing the source string, saving
      *object creation.
      */
     public void setSource(String newSource)


-- 
Vladimir Weinstein, IBM GCoC-Unicode/ICU  San Jose, CA weiv@jtcsv.com

_______________________________________________
icu mailing list
icu@oss.software.ibm.com
http://oss.software.ibm.com/developerworks/oss/mailman/listinfo/icu
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic