Exemplo n.º 1
0
 /// <summary>
 /// Gets an enummerator to enumerate over all elements in this sequence.
 /// </summary>
 /// <returns></returns>
 public IEnumerator <KeyValuePair <TKey, TValue> > GetEnumerator()
 {
     foreach (var entry in new IterableWrapper <IMap_IEntry <TKey, TValue> >(map.EntrySet()))
     {
         yield return(new KeyValuePair <TKey, TValue>(entry.GetKey(), entry.GetValue()));
     }
 }
        public virtual bool ClearExpired(DateTime date)
        {
            bool clearedAny = false;

            foreach (KeyValuePair <string, Apache.Http.Cookie.Cookie> entry in cookies.EntrySet
                         ())
            {
                string name = entry.Key;
                Apache.Http.Cookie.Cookie cookie = entry.Value;
                if (cookie.IsExpired(date))
                {
                    // Clear cookies from local store
                    Sharpen.Collections.Remove(cookies, name);
                    DeletePersistedCookie(name);
                    // We've cleared at least one
                    clearedAny = true;
                }
            }
            return(clearedAny);
        }
Exemplo n.º 3
0
        public void TestSetValueWriteThrough()
        {
            ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<Object, Object>(2, 5.0f, 1);
            Assert.IsTrue(map.IsEmpty());
            for (int i = 0; i < 20; i++)
            {
                map.Put(i, i);
            }
            Assert.IsFalse(map.IsEmpty());
            Entry<Object, Object> entry1 = map.EntrySet().Iterator().Next();

            // assert that entry1 is not 16
            Assert.IsTrue(!entry1.Key.Equals(16), "entry is 16, test not valid");

            // remove 16 (a different key) from map
            // which just happens to cause entry1 to be cloned in map
            map.Remove(16);

            entry1.Value = "XYZ";

            Assert.IsTrue(map.ContainsValue("XYZ"));
        }