Пример #1
0
            public void Run()
            {
                int count = AtLeast(Rnd, 10000);

                for (int i = 0; i < count; i++)
                {
                    int j = Rnd.Next(KeyCount);
                    switch (Rnd.Next(5))
                    {
                    case 0:
                        Map.Put(Keys.Get(j), Convert.ToInt32(j));
                        break;

                    case 1:
                        int?v = Map.Get(Keys.Get(j));
                        if (v != null)
                        {
                            Assert.AreEqual(j, (int)v);
                        }
                        break;

                    case 2:
                        Map.Remove(Keys.Get(j));
                        break;

                    case 3:
                        // renew key, the old one will be GCed at some time:
                        Keys.Set(j, new object());
                        break;

                    case 4:
                        // check iterator still working
                        for (IEnumerator <object> it = Map.Keys.GetEnumerator(); it.MoveNext();)
                        {
                            Assert.IsNotNull(it.Current);
                        }
                        break;

                    default:
                        Assert.Fail("Should not get here.");
                        break;
                    }
                }
            }
Пример #2
0
            internal virtual bool Contains(AnyObjectId toFind)
            {
                int i = Index(toFind);

                for (int n = 0; n < MAX_CHAIN; n++)
                {
                    ObjectId obj = ids.Get(i);
                    if (obj == null)
                    {
                        break;
                    }
                    if (AnyObjectId.Equals(obj, toFind))
                    {
                        return(true);
                    }
                    if (++i == ids.Length())
                    {
                        i = 0;
                    }
                }
                return(false);
            }