Ejemplo n.º 1
0
        internal void HandleContractions(int start, int end, int ce32)
        {
            int index = Collation.IndexFromCE32(ce32);

            if ((ce32 & Collation.CONTRACT_SINGLE_CP_NO_MATCH) != 0)
            {
                // No match on the single code point.
                // We are underneath a prefix, and the default mapping is just
                // a fallback to the mappings for a shorter prefix.
                Debug.Assert(unreversedPrefix.Length != 0);
            }
            else
            {
                ce32 = data.GetCE32FromContexts(index); // Default if no suffix match.
                Debug.Assert(!Collation.IsContractionCE32(ce32));
                HandleCE32(start, end, ce32);
            }
            using (CharsTrie.Enumerator suffixes = new CharsTrie(data.contexts, index + 2).GetEnumerator())
            {
                while (suffixes.MoveNext())
                {
                    var e = suffixes.Current;
                    suffix = e.Chars.ToString();
                    AddStrings(start, end, contractions);
                    if (unreversedPrefix.Length != 0)
                    {
                        AddStrings(start, end, expansions);
                    }
                    HandleCE32(start, end, e.Value);
                }
            }
            suffix = null;
        }
Ejemplo n.º 2
0
        private void HandlePrefixes(int start, int end, int ce32)
        {
            int index = Collation.IndexFromCE32(ce32);

            ce32 = data.GetCE32FromContexts(index); // Default if no prefix match.
            HandleCE32(start, end, ce32);
            if (!addPrefixes)
            {
                return;
            }
            using (CharsTrie.Enumerator prefixes = new CharsTrie(data.contexts, index + 2).GetEnumerator())
            {
                while (prefixes.MoveNext())
                {
                    var e = prefixes.Current;
                    SetPrefix(e.Chars);
                    // Prefix/pre-context mappings are special kinds of contractions
                    // that always yield expansions.
                    AddStrings(start, end, contractions);
                    AddStrings(start, end, expansions);
                    HandleCE32(start, end, e.Value);
                }
            }
            ResetPrefix();
        }
Ejemplo n.º 3
0
 private void AddContractions(int c, ICharSequence p, int pidx)
 {
     using (CharsTrie.Enumerator suffixes = new CharsTrie(p, pidx).GetEnumerator())
     {
         while (suffixes.MoveNext())
         {
             var e = suffixes.Current;
             AddSuffix(c, e.Chars);
         }
     }
 }
Ejemplo n.º 4
0
 private void AddPrefixes(CollationData d, int c, string p, int pidx) // ICU4N specific - changed p from ICharSequence to string
 {
     using (CharsTrie.Enumerator prefixes = new CharsTrie(p, pidx).GetEnumerator())
     {
         while (prefixes.MoveNext())
         {
             var e = prefixes.Current;
             AddPrefix(d, e.Chars, c, e.Value);
         }
     }
 }
Ejemplo n.º 5
0
 private void CompareContractions(int c, string p, int pidx, string q, int qidx) // ICU4N specific - changed p and q from ICharSequence to string
 {
     // Parallel iteration over suffixes of both tables.
     using (CharsTrie.Enumerator suffixes = new CharsTrie(p, pidx).GetEnumerator())
         using (CharsTrie.Enumerator baseSuffixes = new CharsTrie(q, qidx).GetEnumerator())
         {
             string ts = null; // Tailoring suffix.
             string bs = null; // Base suffix.
                               // Use a string with two U+FFFF as the limit sentinel.
                               // U+FFFF is untailorable and will not occur in contractions except maybe
                               // as a single suffix character for a root-collator boundary contraction.
             string          none = "\uffff\uffff";
             CharsTrie.Entry te = null, be = null;
             for (; ;)
             {
                 if (ts == null)
                 {
                     if (suffixes.MoveNext())
                     {
                         te = suffixes.Current;
                         ts = te.Chars.ToString();
                     }
                     else
                     {
                         te = null;
                         ts = none;
                     }
                 }
                 if (bs == null)
                 {
                     if (baseSuffixes.MoveNext())
                     {
                         be = baseSuffixes.Current;
                         bs = be.Chars.ToString();
                     }
                     else
                     {
                         be = null;
                         bs = none;
                     }
                 }
                 if (Utility.SameObjects(ts, none) && Utility.SameObjects(bs, none))
                 {
                     break;
                 }
                 int cmp = ts.CompareToOrdinal(bs);
                 if (cmp < 0)
                 {
                     // ts occurs in the tailoring but not in the base.
                     AddSuffix(c, ts);
                     te = null;
                     ts = null;
                 }
                 else if (cmp > 0)
                 {
                     // bs occurs in the base but not in the tailoring.
                     AddSuffix(c, bs);
                     be = null;
                     bs = null;
                 }
                 else
                 {
                     suffix = ts;
                     Compare(c, te.Value, be.Value);
                     suffix = null;
                     te     = be = null;
                     ts     = bs = null;
                 }
             }
         }
 }
Ejemplo n.º 6
0
 private void ComparePrefixes(int c, string p, int pidx, string q, int qidx) // ICU4N specific - changed p and q from ICharSequence to string
 {
     // Parallel iteration over prefixes of both tables.
     using (CharsTrie.Enumerator prefixes = new CharsTrie(p, pidx).GetEnumerator())
         using (CharsTrie.Enumerator basePrefixes = new CharsTrie(q, qidx).GetEnumerator())
         {
             string tp = null; // Tailoring prefix.
             string bp = null; // Base prefix.
                               // Use a string with a U+FFFF as the limit sentinel.
                               // U+FFFF is untailorable and will not occur in prefixes.
             string          none = "\uffff";
             CharsTrie.Entry te = null, be = null;
             for (; ;)
             {
                 if (tp == null)
                 {
                     if (prefixes.MoveNext())
                     {
                         te = prefixes.Current;
                         tp = te.Chars.ToString();
                     }
                     else
                     {
                         te = null;
                         tp = none;
                     }
                 }
                 if (bp == null)
                 {
                     if (basePrefixes.MoveNext())
                     {
                         be = basePrefixes.Current;
                         bp = be.Chars.ToString();
                     }
                     else
                     {
                         be = null;
                         bp = none;
                     }
                 }
                 if (Utility.SameObjects(tp, none) && Utility.SameObjects(bp, none))
                 {
                     break;
                 }
                 int cmp = tp.CompareToOrdinal(bp);
                 if (cmp < 0)
                 {
                     // tp occurs in the tailoring but not in the base.
                     Debug.Assert(te != null);
                     AddPrefix(data, tp, c, te.Value);
                     te = null;
                     tp = null;
                 }
                 else if (cmp > 0)
                 {
                     // bp occurs in the base but not in the tailoring.
                     Debug.Assert(be != null);
                     AddPrefix(baseData, bp, c, be.Value);
                     be = null;
                     bp = null;
                 }
                 else
                 {
                     SetPrefix(tp);
                     Debug.Assert(te != null && be != null);
                     Compare(c, te.Value, be.Value);
                     ResetPrefix();
                     te = be = null;
                     tp = bp = null;
                 }
             }
         }
 }