Example #1
0
        public void TestUnicodeSet()
        {
            String[] array = new String[] { "a", "b", "c", "{de}" };
            IList    list  = ILOG.J2CsMapping.Collections.Arrays.AsList(array);

            ILOG.J2CsMapping.Collections.ISet aset = new HashedSet(list);
            Logln(" *** The source set's size is: " + aset.Count);
            // The size reads 4
            UnicodeSet set = new UnicodeSet();

            set.Clear();
            set.AddAll(aset);
            Logln(" *** After addAll, the UnicodeSet size is: " + set.Size());
            // The size should also read 4, but 0 is seen instead
        }
Example #2
0
        protected internal void DoAt(UnicodeSet c)
        {
            if (c.Size() == 0)
            {
                DoBefore(c, null);
            }
            UnicodeSetIterator it = new UnicodeSetIterator(c);
            bool   first          = true;
            Object last           = null;
            Object item;

            Visitor.CodePointRange cpr0 = new Visitor.CodePointRange();
            Visitor.CodePointRange cpr1 = new Visitor.CodePointRange();
            Visitor.CodePointRange cpr;

            while (it.NextRange())
            {
                if (it.codepoint == IBM.ICU.Text.UnicodeSetIterator.IS_STRING)
                {
                    item = it.str0;
                }
                else
                {
                    cpr = (last == (Object)cpr0) ? cpr1 : cpr0;      // make sure we don't override
                    // last
                    cpr.codepoint    = it.codepoint;
                    cpr.codepointEnd = it.codepointEnd;
                    item             = cpr;
                }
                if (!first)
                {
                    DoBefore(c, item);
                    first = true;
                }
                else
                {
                    DoBetween(c, last, item);
                }
                DoAt(last = item);
            }
            DoAfter(c, last);
        }
Example #3
0
 internal void CheckDelimiters()
 {
     if (m_delimiters_ == null || m_delimiters_.Size() == 0)
     {
         delims = new bool[0];
     }
     else
     {
         int maxChar = m_delimiters_.GetRangeEnd(m_delimiters_
                                                 .GetRangeCount() - 1);
         if (maxChar < 0x7f)
         {
             delims = new bool[maxChar + 1];
             for (int i = 0, ch; -1 != (ch = m_delimiters_.CharAt(i)); ++i)
             {
                 delims[ch] = true;
             }
         }
         else
         {
             delims = null;
         }
     }
 }
Example #4
0
 protected internal override void AddTo(Pick.Target target)
 {
     target.Append(source.CharAt(IBM.ICU.Charset.Pick.PickMthd(target.random, 0,
                                                               source.Size() - 1)));
 }
Example #5
0
 static public int PickMthd(Random random_0, UnicodeSet s)
 {
     return(s.CharAt(PickMthd(random_0, 0, s.Size() - 1)));
 }