public virtual void TestByteArrayKeys() { byte[] key1 = new byte[] { 1, 2, 3 }; byte[] key2 = new byte[] { 3, 2, 1 }; byte[] key3 = new byte[] { 3, 2, 1 }; // same values as key2 Hashtable4 table = new Hashtable4(2); table.Put(key1, "foo"); table.Put(key2, "bar"); Assert.AreEqual("foo", table.Get(key1)); Assert.AreEqual("bar", table.Get(key2)); Assert.AreEqual(2, CountKeys(table)); Assert.AreEqual(2, table.Size()); table.Put(key3, "baz"); Assert.AreEqual("foo", table.Get(key1)); Assert.AreEqual("baz", table.Get(key2)); Assert.AreEqual(2, CountKeys(table)); Assert.AreEqual(2, table.Size()); Assert.AreEqual("baz", table.Remove(key2)); Assert.AreEqual(1, CountKeys(table)); Assert.AreEqual(1, table.Size()); Assert.AreEqual("foo", table.Remove(key1)); Assert.AreEqual(0, CountKeys(table)); Assert.AreEqual(0, table.Size()); }
private ClassMetadata ReadClassMetadata(IReflectClass reflectClazz) { ClassMetadata clazz = (ClassMetadata)_classMetadataByBytes.Remove(GetNameBytes(reflectClazz .GetName())); if (clazz == null) { return(null); } return(ReadClassMetadata(clazz, reflectClazz)); }
public void RefreshClassCache(ClassMetadata clazz, IReflectClass oldReflector) { if (clazz.StateUnread()) { _classMetadataByBytes.Put(clazz.ReadName(_systemTransaction), clazz); } else { if (oldReflector != null) { _classMetadataByClass.Remove(oldReflector); } _classMetadataByClass.Put(clazz.ClassReflector(), clazz); } }
public virtual void TestContainsKey() { Hashtable4 table = new Hashtable4(); Assert.IsFalse(table.ContainsKey(null)); Assert.IsFalse(table.ContainsKey("foo")); table.Put("foo", null); Assert.IsTrue(table.ContainsKey("foo")); table.Put("bar", "baz"); Assert.IsTrue(table.ContainsKey("bar")); Assert.IsFalse(table.ContainsKey("baz")); Assert.IsTrue(table.ContainsKey("foo")); table.Remove("foo"); Assert.IsTrue(table.ContainsKey("bar")); Assert.IsFalse(table.ContainsKey("foo")); }
internal ClassMetadata ProduceClassMetadata(IReflectClass reflectClazz) { ClassMetadata classMetadata = ClassMetadataForReflectClass(reflectClazz); if (classMetadata != null) { return(classMetadata); } ClassMetadata classBeingCreated = (ClassMetadata)_creating.Get(reflectClazz); if (classBeingCreated != null) { return(classBeingCreated); } ClassMetadata newClassMetadata = new ClassMetadata(Container(), reflectClazz); _creating.Put(reflectClazz, newClassMetadata); try { if (!CreateClassMetadata(newClassMetadata, reflectClazz)) { return(null); } // ObjectContainerBase#createClassMetadata may add the ClassMetadata already, // so we have to check again if (!IsRegistered(reflectClazz)) { AddClassMetadata(newClassMetadata); _classInits.Process(newClassMetadata); } else { RegisterClassMetadataById(newClassMetadata); if (newClassMetadata.AspectsAreNull()) { _classInits.Process(newClassMetadata); } } Container().SetDirtyInSystemTransaction(this); } finally { _creating.Remove(reflectClazz); } return(newClassMetadata); }
public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer ) { long longKey = (((long)key)); if (_last == null) { object lastValue = producer.Apply(((long)key)); if (lastValue == null) { return(null); } _size = 1; LRULongCache.Entry lastEntry = new LRULongCache.Entry(longKey, lastValue); _slots.Put(longKey, lastEntry); _first = lastEntry; _last = lastEntry; return(lastValue); } LRULongCache.Entry entry = (LRULongCache.Entry)_slots.Get(longKey); if (entry == null) { if (_size >= _maxSize) { LRULongCache.Entry oldEntry = (LRULongCache.Entry)_slots.Remove(_last._key); _last = oldEntry._previous; _last._next = null; if (null != finalizer) { finalizer.Apply((object)oldEntry._value); } _size--; } object newValue = producer.Apply(((long)key)); if (newValue == null) { return(null); } _size++; LRULongCache.Entry newEntry = new LRULongCache.Entry(longKey, newValue); _slots.Put(longKey, newEntry); _first._previous = newEntry; newEntry._next = _first; _first = newEntry; return(newValue); } if (_first == entry) { return((object)entry._value); } LRULongCache.Entry previous = entry._previous; entry._previous = null; if (_last == entry) { _last = previous; } previous._next = entry._next; if (previous._next != null) { previous._next._previous = previous; } _first._previous = entry; entry._next = _first; _first = entry; return((object)entry._value); }
public void QueryResultFinalized(int queryResultID) { _queryResults.Remove(queryResultID); }
// do nothing public override void Delete(string path) { _memoryFiles.Remove(path); }
public void Visit(object a_object) { semaphores.Remove(a_object); }