Example #1
0
 private IList GetIntersectingObjects(float[] r,
                                      CollisionQuery query)
 {
     lock (cacheSet)
     {
         CollectionUtils.Clear(cacheSet);
         GetIntersectingObjects(r, query, cacheSet, this.bspTree);
         List <Actor> result = new List <Actor>(cacheSet.Count);
         for (IEnumerator it = cacheSet.GetEnumerator(); it.MoveNext();)
         {
             result.Add((Actor)it.Current);
         }
         return(result);
     }
 }
Example #2
0
        /// <exclude/>
        /// <summary>
        /// Simple implementation of permutation. <br>
        /// <b>Warning: The strings are not guaranteed to be in any particular
        /// order.</b>
        /// </summary>
        ///
        /// <param name="source">the string to find permutations for</param>
        /// <param name="skipZeros">set to true to skip characters with canonical combining classzero</param>
        /// <param name="output">the set to add the results to</param>
        public static void Permute(String source, bool skipZeros, ILOG.J2CsMapping.Collections.ISet output)
        {
            // TODO: optimize
            // if (PROGRESS) System.out.println("Permute: " + source);

            // optimization:
            // if zero or one character, just return a set with it
            // we check for length < 2 to keep from counting code points all the
            // time
            if (source.Length <= 2 && IBM.ICU.Text.UTF16.CountCodePoint(source) <= 1)
            {
                ILOG.J2CsMapping.Collections.Generics.Collections.Add(output, source);
                return;
            }

            // otherwise iterate through the string, and recursively permute all the
            // other characters
            ILOG.J2CsMapping.Collections.ISet subpermute = new HashedSet();
            int cp;

            for (int i = 0; i < source.Length; i += IBM.ICU.Text.UTF16.GetCharCount(cp))
            {
                cp = IBM.ICU.Text.UTF16.CharAt(source, i);

                // optimization:
                // if the character is canonical combining class zero,
                // don't permute it
                if (skipZeros && i != 0 && IBM.ICU.Lang.UCharacter.GetCombiningClass(cp) == 0)
                {
                    // System.out.println("Skipping " +
                    // Utility.hex(UTF16.valueOf(source, i)));
                    continue;
                }

                // see what the permutations of the characters before and after this
                // one are
                ILOG.J2CsMapping.Collections.Collections.Clear(subpermute);
                Permute(source.Substring(0, (i) - (0))
                        + source.Substring(i + IBM.ICU.Text.UTF16.GetCharCount(cp)), skipZeros,
                        subpermute);

                // prefix this character to all of them
                String    chStr = IBM.ICU.Text.UTF16.ValueOf(source, i);
                IIterator it    = new ILOG.J2CsMapping.Collections.IteratorAdapter(subpermute.GetEnumerator());
                while (it.HasNext())
                {
                    String piece = chStr + (String)it.Next();
                    // if (PROGRESS) System.out.println("  Piece: " + piece);
                    ILOG.J2CsMapping.Collections.Generics.Collections.Add(output, piece);
                }
            }
        }
Example #3
0
        // we have a segment, in NFD. Find all the strings that are canonically
        // equivalent to it.
        private String[] GetEquivalents(String segment)
        {
            ILOG.J2CsMapping.Collections.ISet result       = new HashedSet();
            ILOG.J2CsMapping.Collections.ISet basic        = GetEquivalents2(segment);
            ILOG.J2CsMapping.Collections.ISet permutations = new HashedSet();

            // now get all the permutations
            // add only the ones that are canonically equivalent
            // TODO: optimize by not permuting any class zero.
            IIterator it = new ILOG.J2CsMapping.Collections.IteratorAdapter(basic.GetEnumerator());

            while (it.HasNext())
            {
                String item = (String)it.Next();
                ILOG.J2CsMapping.Collections.Collections.Clear(permutations);
                Permute(item, SKIP_ZEROS, permutations);
                IIterator it2 = new ILOG.J2CsMapping.Collections.IteratorAdapter(permutations.GetEnumerator());
                while (it2.HasNext())
                {
                    String possible = (String)it2.Next();

                    /*
                     * String attempt = Normalizer.normalize(possible,
                     * Normalizer.DECOMP, 0); if (attempt.equals(segment)) {
                     */
                    if (IBM.ICU.Text.Normalizer.Compare(possible, segment, 0) == 0)
                    {
                        if (PROGRESS)
                        {
                            System.Console.Out.WriteLine("Adding Permutation: "
                                                         + IBM.ICU.Impl.Utility.Hex(possible));
                        }
                        ILOG.J2CsMapping.Collections.Generics.Collections.Add(result, possible);
                    }
                    else
                    {
                        if (PROGRESS)
                        {
                            System.Console.Out.WriteLine("-Skipping Permutation: "
                                                         + IBM.ICU.Impl.Utility.Hex(possible));
                        }
                    }
                }
            }

            // convert into a String[] to clean up storage
            String[] finalResult = new String[result.Count];
            ILOG.J2CsMapping.Collections.Generics.Collections.ToArray(result, finalResult);
            return(finalResult);
        }
Example #4
0
        // return a collection of unique factories, might be fewer than requested
        internal ICollection GetFactoryCollection(int requested)
        {
            ILOG.J2CsMapping.Collections.ISet locales = new HashedSet();
            for (int i = 0; i < requested; ++i)
            {
                ILOG.J2CsMapping.Collections.Generics.Collections.Add(locales, GetCLV());
            }
            IList     factories_0 = new ArrayList(locales.Count);
            IIterator iter        = new ILOG.J2CsMapping.Collections.IteratorAdapter(locales.GetEnumerator());

            while (iter.HasNext())
            {
                ILOG.J2CsMapping.Collections.Generics.Collections.Add(factories_0, new ICUServiceThreadTest.TestFactory((String)iter.Next()));
            }
            return(factories_0);
        }
Example #5
0
        public void test_iterator()
        {
            // Test for method java.util.Iterator java.util.HashSet.iterator()
            IEnumerator i = hs.GetEnumerator();
            int         x = 0;

            while (i.MoveNext())
            {
                Assertion.Assert("Failed to iterate over all elements", hs.Contains(i
                                                                                    .Current));
                ++x;
            }
            Assertion.Assert("Returned iteration of incorrect size", hs.Count == x);

            /*HashedSet s = new HashedSet();
             * s.Add(null);
             * Assertion.Assert("Cannot handle null", s.GetEnumerator().MoveNext());*/
        }
Example #6
0
        public void test_clear()
        {
            // Test for method void java.util.HashSet.clear()
            ISet orgSet = new HashedSet();

            for (int i1 = 0; i1 < objArray.Length; i1++)
            {
                hs.Add(objArray[i1]);
            }
            hs.Clear();
            IEnumerator i = orgSet.GetEnumerator();

            Assertion.AssertEquals("Returned non-zero size after clear", 0, hs.Count);
            while (i.MoveNext())
            {
                Assertion.Assert("Failed to clear set", !hs.Contains(i.Current));
            }
        }
Example #7
0
        private string GetExpression()
        {
            if (!HasMembers)
            {
                return(string.Empty);
            }
            var clause = new StringBuilder(groups.Count * 32 + 9);

            IEnumerator <string> iter = groups.GetEnumerator();

            iter.MoveNext();
            clause.Append(iter.Current);
            while (iter.MoveNext())
            {
                clause.Append(StringHelper.CommaSpace).Append(iter.Current);
            }

            return(clause.ToString());
        }
Example #8
0
        internal String ShowDiff(ILOG.J2CsMapping.Collections.ISet a, ILOG.J2CsMapping.Collections.ISet b)
        {
            ILOG.J2CsMapping.Collections.ISet temp = new HashedSet();
            ILOG.J2CsMapping.Collections.Generics.Collections.AddAll(a, temp);
            temp.RemoveAll(b);
            if (temp.Count == 0)
            {
                return("");
            }
            StringBuilder buffer = new StringBuilder();
            IIterator     it     = new ILOG.J2CsMapping.Collections.IteratorAdapter(temp.GetEnumerator());

            while (it.HasNext())
            {
                if (buffer.Length != 0)
                {
                    buffer.Append(", ");
                }
                buffer.Append(it.Next().ToString());
            }
            return(buffer.ToString());
        }
Example #9
0
		public void TransientOrphanDelete()
		{
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			Baz baz = new Baz();
			ISet bars = new HashedSet();
			baz.CascadingBars = bars;
			bars.Add(new Bar());
			bars.Add(new Bar());
			bars.Add(new Bar());
			IList foos = new ArrayList();
			foos.Add(new Foo());
			foos.Add(new Foo());
			baz.FooBag = foos;
			s.Save(baz);

			IEnumerator enumer = new JoinedEnumerable(new IEnumerable[] {foos, bars}).GetEnumerator();
			while (enumer.MoveNext())
			{
				FooComponent cmp = ((Foo) enumer.Current).Component;
				s.Delete(cmp.Glarch);
				cmp.Glarch = null;
			}

			t.Commit();
			s.Close();

			enumer = bars.GetEnumerator();
			enumer.MoveNext();
			bars.Remove(enumer.Current);
			foos.RemoveAt(1);
			s = OpenSession();
			t = s.BeginTransaction();
			s.Update(baz);
			Assert.AreEqual(2, s.CreateQuery("from Bar bar").List().Count);
			Assert.AreEqual(3, s.CreateQuery("from Foo foo").List().Count);
			t.Commit();
			s.Close();

			foos.RemoveAt(0);
			s = OpenSession();
			t = s.BeginTransaction();
			s.Update(baz);
			enumer = bars.GetEnumerator();
			enumer.MoveNext();
			bars.Remove(enumer.Current);
			s.Delete(baz);
			s.Flush();
			Assert.AreEqual(0, s.CreateQuery("from Foo foo").List().Count);
			t.Commit();
			s.Close();
		}
Example #10
0
 /// <summary> Returns an {@link Iterator} over the {@link Edge}s in this graph,
 /// in the order in which they were added.
 ///
 /// </summary>
 /// <returns> an iterator over the edges
 ///
 /// </returns>
 /// <seealso cref="Add(Edge)">
 /// </seealso>
 public IEnumerator EdgeIterator()
 {
     return(edges.GetEnumerator());
 }