Exemple #1
0
        protected virtual Trie2CharSequenceValues Next()
        {
            int c   = Character.CodePointAt(text, index);
            int val = trie2.Get(c);

            fResults.Index     = index;
            fResults.CodePoint = c;
            fResults.Value     = val;
            index++;
            if (c >= 0x10000)
            {
                index++;
            }
            return(fResults);
        }
Exemple #2
0
        /// <summary>
        /// The main Next() function for <see cref="Trie2"/> iterators
        /// </summary>
        private Trie2Range Next()
        {
            //if (!hasNext())
            //{
            //    throw new NoSuchElementException();
            //}
            if (nextStart >= limitCP)
            {
                // Switch over from iterating normal code point values to
                //   doing the alternate lead-surrogate values.
                doingCodePoints = false;
                nextStart       = 0xd800;
            }
            int endOfRange = 0;
            int val        = 0;
            int mappedVal  = 0;

            if (doingCodePoints)
            {
                // Iteration over code point values.
                val        = trie2.Get(nextStart);
                mappedVal  = mapper.Map(val);
                endOfRange = trie2.RangeEnd(nextStart, limitCP, val);
                // Loop once for each range in the Trie2 with the same raw (unmapped) value.
                // Loop continues so long as the mapped values are the same.
                for (; ;)
                {
                    if (endOfRange >= limitCP - 1)
                    {
                        break;
                    }
                    val = trie2.Get(endOfRange + 1);
                    if (mapper.Map(val) != mappedVal)
                    {
                        break;
                    }
                    endOfRange = trie2.RangeEnd(endOfRange + 1, limitCP, val);
                }
            }
            else
            {
                // Iteration over the alternate lead surrogate values.
                val        = trie2.GetFromU16SingleLead((char)nextStart);
                mappedVal  = mapper.Map(val);
                endOfRange = RangeEndLS((char)nextStart);
                // Loop once for each range in the Trie2 with the same raw (unmapped) value.
                // Loop continues so long as the mapped values are the same.
                for (; ;)
                {
                    if (endOfRange >= 0xdbff)
                    {
                        break;
                    }
                    val = trie2.GetFromU16SingleLead((char)(endOfRange + 1));
                    if (mapper.Map(val) != mappedVal)
                    {
                        break;
                    }
                    endOfRange = RangeEndLS((char)(endOfRange + 1));
                }
            }
            returnValue.StartCodePoint  = nextStart;
            returnValue.EndCodePoint    = endOfRange;
            returnValue.Value           = mappedVal;
            returnValue.IsLeadSurrogate = !doingCodePoints;
            nextStart = endOfRange + 1;
            return(returnValue);
        }