public virtual void TestContainsAll() { var a = new Item(42); var b = new Item(a.id + 1); var c = new Item(b.id + 1); var a_ = new Item(a.id); var needle = new Collection4(); var haystack = new Collection4(); haystack.Add(a); needle.Add(a); needle.Add(b); Assert.IsFalse(haystack.ContainsAll(needle)); needle.Remove(b); Assert.IsTrue(haystack.ContainsAll(needle)); needle.Add(b); haystack.Add(b); Assert.IsTrue(haystack.ContainsAll(needle)); needle.Add(a_); Assert.IsTrue(haystack.ContainsAll(needle)); needle.Add(c); Assert.IsFalse(haystack.ContainsAll(needle)); needle.Clear(); Assert.IsTrue(haystack.ContainsAll(needle)); haystack.Clear(); Assert.IsTrue(haystack.ContainsAll(needle)); }
private CompositeIterator4 NewIterator() { Collection4 iterators = new Collection4(); iterators.Add(IntArrays4.NewIterator(new int[] { 1, 2, 3 })); iterators.Add(IntArrays4.NewIterator(new int[] { })); iterators.Add(IntArrays4.NewIterator(new int[] { 4 })); iterators.Add(IntArrays4.NewIterator(new int[] { 5, 6 })); CompositeIterator4 iterator = new CompositeIterator4(iterators.GetEnumerator()); return iterator; }
public virtual void TestContains() { object a = new object(); Collection4 c = new Collection4(); c.Add(new object()); Assert.IsFalse(c.Contains(a)); c.Add(a); Assert.IsTrue(c.Contains(a)); c.Remove(a); Assert.IsFalse(c.Contains(a)); }
public virtual IEnumerator IteratorFor(object collection) { IDictionary map = (IDictionary)collection; Collection4 result = new Collection4(); IEnumerator it = map.GetEnumerator(); while (it.MoveNext()) { DictionaryEntry entry = (DictionaryEntry)it.Current; result.Add(entry.Key); result.Add(entry.Value); } return result.GetEnumerator(); }
internal virtual void CacheDirty(Collection4 col) { if (!BitIsTrue(Const4.CachedDirty)) { BitTrue(Const4.CachedDirty); col.Add(this); } }
public ExcludingReflector(ByRef loaderClass, Type[] excludedClasses) { _excludedClasses = new Collection4(); for (int claxxIndex = 0; claxxIndex < excludedClasses.Length; ++claxxIndex) { Type claxx = excludedClasses[claxxIndex]; _excludedClasses.Add(claxx.FullName); } }
public ExcludingReflector(Type[] excludedClasses) { _excludedClasses = new Collection4(); for (var claxxIndex = 0; claxxIndex < excludedClasses.Length; ++claxxIndex) { var claxx = excludedClasses[claxxIndex]; _excludedClasses.Add(claxx.FullName); } }
public static Collection4 AsList(object[] arr) { var coll = new Collection4(); for (var arrIdx = 0; arrIdx < arr.Length; arrIdx++) { coll.Add(arr[arrIdx]); } return(coll); }
private Collection4 Copy(IEnumerable subject) { Collection4 result = new Collection4(); IEnumerator it = subject.GetEnumerator(); while (it.MoveNext()) { result.Add(it.Current); } return result; }
public virtual object DeepClone(object newParent) { var col = new Collection4 (); object element = null; var i = InternalIterator(); while (i.MoveNext()) { element = i.Current; if (element is IDeepClone) { col.Add(((IDeepClone) element).DeepClone(newParent)); } else { col.Add(element); } } return col; }
public virtual object DeepClone(object newParent) { Db4objects.Db4o.Foundation.Collection4 col = new Db4objects.Db4o.Foundation.Collection4 (); object element = null; IEnumerator i = InternalIterator(); while (i.MoveNext()) { element = i.Current; if (element is IDeepClone) { col.Add(((IDeepClone)element).DeepClone(newParent)); } else { col.Add(element); } } return(col); }
private void CreateDatabase(string fileName) { IObjectContainer db = Db4oEmbedded.OpenFile(Config(), fileName); var removed = new Collection4(); for (var idx = 0; idx < NumItemsPerClass; idx++) { var itemA = new ItemA(idx); var itemB = new ItemB(FillStr ('x', idx)); db.Store(itemA); db.Store(itemB); if ((idx%DeleteRatio) == 0) { removed.Add(itemA); removed.Add(itemB); } } db.Commit(); DeleteAndReadd(db, removed); db.Close(); }
public virtual object DeepClone(object newParent) { var col = new Collection4 (); object element = null; var i = InternalIterator(); while (i.MoveNext()) { element = i.Current; if (element is IDeepClone) { col.Add(((IDeepClone)element).DeepClone(newParent)); } else { col.Add(element); } } return(col); }
public object Run() { _enclosing.UnsafeWaitForNext(); var i = 0; while (_enclosing.HasNext()) { i++; target.Add(_enclosing.UnsafeNext()); } return(i); }
public virtual IObjectSet ObjectsChangedSinceLastReplication(Type clazz) { Collection4 result = new Collection4(); for (IEnumerator iterator = StoredObjectsCollection(clazz).GetEnumerator(); iterator .MoveNext(); ) { object candidate = iterator.Current; if (WasChangedSinceLastReplication(candidate)) { result.Add(candidate); } } return new ObjectSetCollection4Facade(result); }
public static IEnumerator Iterate(List4 list) { if (list == null) { return(EmptyIterator); } Collection4 collection = new Collection4(); while (list != null) { collection.Add(list._element); list = ((List4)list._next); } return(collection.GetEnumerator()); }
private void CollectKnownClass(Collection4 classes, IReflectClass clazz) { if (IsInternalClass(clazz)) { return; } if (!HasIdentity(clazz)) { return; } if (clazz.IsArray()) { return; } classes.Add(clazz); }
public virtual IConstraint[] ToArray() { lock (_cluster) { Collection4 all = new Collection4(); for (int i = 0; i < _constraints.Length; i++) { ClusterConstraint c = (ClusterConstraint)_constraints[i]; for (int j = 0; j < c._constraints.Length; j++) { all.Add(c._constraints[j]); } } IConstraint[] res = new IConstraint[all.Size()]; all.ToArray(res); return res; } }
public static void SameContent(IEnumerator expected, IEnumerator actual) { Collection4 allExpected = new Collection4(); while (expected.MoveNext()) { allExpected.Add(expected.Current); } while (actual.MoveNext()) { object current = actual.Current; bool removed = allExpected.Remove(current); if (!removed) { Unexpected(current); } } Assert.IsTrue(allExpected.IsEmpty(), allExpected.ToString()); }
private IEnumerable RandomPositiveIntegersWithoutDuplicates(int keyCount) { var generator = Generators.Take(keyCount, Streams.RandomIntegers()); var res = new Collection4(); var i = generator.GetEnumerator(); while (i.MoveNext()) { var currentInteger = (int) i.Current; if (currentInteger < 0) { currentInteger = -currentInteger; } if (!res.Contains(currentInteger)) { res.Add(currentInteger); } } return res; }
private IObjectInfoCollection DecodeObjectInfoCollection(ByteArrayInputStream @is , IObjectInfoEncoder encoder) { var collection = new Collection4(); while (true) { var info = encoder.Decode(@is); if (null == info) { break; } collection.Add(info); } return new ObjectInfoCollectionImpl(collection); }
internal static void FlattenCollection1(ObjectContainerBase stream, Object obj, Collection4 collection4) { Array arr = obj as Array; if (arr != null) { IReflectArray reflectArray = stream.Reflector().Array(); Object[] flat = new Object[arr.Length]; reflectArray.Flatten(obj, reflectArray.Dimensions(obj), 0, flat, 0); for (int i = 0; i < flat.Length; i++) { FlattenCollection1(stream, flat[i], collection4); } } else { // If obj implements IEnumerable, add all elements to collection4 IEnumerator enumerator = GetCollectionEnumerator(obj, true); // Add elements to collection if conversion was succesful if (enumerator != null) { if (enumerator is IDictionaryEnumerator) { IDictionaryEnumerator dictEnumerator = enumerator as IDictionaryEnumerator; while (enumerator.MoveNext()) { FlattenCollection1(stream, dictEnumerator.Key, collection4); } } else { while (enumerator.MoveNext()) { // recursive call to flatten Collections in Collections FlattenCollection1(stream, enumerator.Current, collection4); } } } else { // If obj is not a Collection, it still needs to be collected. collection4.Add(obj); } } }
internal virtual void CreateCandidates(Collection4 a_candidateCollection) { IEnumerator j = a_candidateCollection.GetEnumerator(); while (j.MoveNext()) { QCandidates candidates = (QCandidates)j.Current; if (candidates.TryAddConstraint(this)) { i_candidates = candidates; return; } } i_candidates = new QCandidates((LocalTransaction)i_trans, GetYapClass(), GetField (), false); i_candidates.AddConstraint(this); a_candidateCollection.Add(i_candidates); }
public void WriteAllClasses() { Collection4 deadClasses = new Collection4(); IStoredClass[] storedClasses = StoredClasses(); for (int i = 0; i < storedClasses.Length; i++) { ClassMetadata clazz = (ClassMetadata)storedClasses[i]; clazz.SetStateDirty(); if (clazz.StateDead()) { deadClasses.Add(clazz); clazz.SetStateOK(); } } for (int i = 0; i < storedClasses.Length; i++) { ClassMetadata clazz = (ClassMetadata)storedClasses[i]; clazz.Write(_systemTransaction); } IEnumerator it = deadClasses.GetEnumerator(); while (it.MoveNext()) { ((ClassMetadata)it.Current).SetStateDead(); } }
private void EnsureAllClassesRead() { bool allClassesRead = false; while (!allClassesRead) { Collection4 unreadClasses = new Collection4(); int numClasses = _classes.Size(); IEnumerator classIter = _classes.GetEnumerator(); while (classIter.MoveNext()) { ClassMetadata clazz = (ClassMetadata)classIter.Current; if (clazz.StateUnread()) { unreadClasses.Add(clazz); } } IEnumerator unreadIter = unreadClasses.GetEnumerator(); while (unreadIter.MoveNext()) { ClassMetadata clazz = (ClassMetadata)unreadIter.Current; clazz = ReadClassMetadata(clazz, null); if (clazz.ClassReflector() == null) { clazz.ForceRead(); } } allClassesRead = (_classes.Size() == numClasses); } ApplyReadAs(); }
public Collection4 ForInterface(IReflectClass claxx) { Collection4 col = new Collection4(); ClassMetadataIterator i = Iterator(); while (i.MoveNext()) { ClassMetadata clazz = i.CurrentClass(); IReflectClass candidate = clazz.ClassReflector(); if (!candidate.IsInterface()) { if (claxx.IsAssignableFrom(candidate)) { col.Add(clazz); IEnumerator j = new Collection4(col).GetEnumerator(); while (j.MoveNext()) { ClassMetadata existing = (ClassMetadata)j.Current; if (existing != clazz) { ClassMetadata higher = clazz.GetHigherHierarchy(existing); if (higher != null) { if (higher == clazz) { col.Remove(existing); } else { col.Remove(clazz); } } } } } } } return col; }
public virtual IEnumerator Values() { Collection4 values = new Collection4(); for (IEnumerator sIter = cache.GetEnumerator(); sIter.MoveNext(); ) { string s = ((string)sIter.Current); values.Add(s); } return values.GetEnumerator(); }
public static IEnumerator Iterate(List4 list) { if (list == null) { return EmptyIterator; } Collection4 collection = new Collection4(); while (list != null) { collection.Add(list._element); list = ((List4)list._next); } return collection.GetEnumerator(); }
private void CreateDatabase(string fileName, int blockSize) { IObjectContainer db = Db4oEmbedded.OpenFile(Config(blockSize), fileName); Collection4 removed = new Collection4(); for (int idx = 0; idx < NumItemsPerClass; idx++) { BlockSizeDefragTestCase.ItemA itemA = new BlockSizeDefragTestCase.ItemA(idx); BlockSizeDefragTestCase.ItemB itemB = new BlockSizeDefragTestCase.ItemB(FillStr('x' , idx)); db.Store(itemA); db.Store(itemB); if ((idx % DeleteRatio) == 0) { removed.Add(itemA); removed.Add(itemB); } } db.Commit(); DeleteAndReadd(db, removed); db.Close(); }
private void CollectLeavesFromJoinConstraint(Collection4 leaves, QCon constraint) { if (constraint is QConJoin) { CollectLeavesFromJoin(leaves, (QConJoin)constraint); } else { if (!leaves.ContainsByIdentity(constraint)) { leaves.Add(constraint); } } }
private void CollectTopLevelJoins(Collection4 joins, QCon constraintWithJoins) { IEnumerator i = constraintWithJoins.IterateJoins(); while (i.MoveNext()) { QConJoin join = (QConJoin)i.Current; if (!join.HasJoins()) { if (!joins.ContainsByIdentity(join)) { joins.Add(join); } } else { CollectTopLevelJoins(joins, join); } } }
/// <exception cref="System.Exception"></exception> public static void AssertAllSlotsFreed(LocalTransaction trans, BTree bTree, ICodeBlock block) { LocalObjectContainer container = (LocalObjectContainer)trans.Container(); ITransactionalIdSystem idSystem = trans.IdSystem(); IEnumerator allSlotIDs = bTree.AllNodeIds(trans.SystemTransaction()); Collection4 allSlots = new Collection4(); while (allSlotIDs.MoveNext()) { int slotID = ((int)allSlotIDs.Current); Slot slot = idSystem.CurrentSlot(slotID); allSlots.Add(slot); } Slot bTreeSlot = idSystem.CurrentSlot(bTree.GetID()); allSlots.Add(bTreeSlot); Collection4 freedSlots = new Collection4(); IFreespaceManager freespaceManager = container.FreespaceManager(); container.InstallDebugFreespaceManager(new FreespaceManagerForDebug(new _ISlotListener_99 (freedSlots))); block.Run(); container.InstallDebugFreespaceManager(freespaceManager); Assert.IsTrue(freedSlots.ContainsAll(allSlots.GetEnumerator())); }
public virtual void TestContainsAll() { Collection4TestCase.Item a = new Collection4TestCase.Item(42); Collection4TestCase.Item b = new Collection4TestCase.Item(a.id + 1); Collection4TestCase.Item c = new Collection4TestCase.Item(b.id + 1); Collection4TestCase.Item a_ = new Collection4TestCase.Item(a.id); Collection4 needle = new Collection4(); Collection4 haystack = new Collection4(); haystack.Add(a); needle.Add(a); needle.Add(b); Assert.IsFalse(haystack.ContainsAll(needle)); needle.Remove(b); Assert.IsTrue(haystack.ContainsAll(needle)); needle.Add(b); haystack.Add(b); Assert.IsTrue(haystack.ContainsAll(needle)); needle.Add(a_); Assert.IsTrue(haystack.ContainsAll(needle)); needle.Add(c); Assert.IsFalse(haystack.ContainsAll(needle)); needle.Clear(); Assert.IsTrue(haystack.ContainsAll(needle)); haystack.Clear(); Assert.IsTrue(haystack.ContainsAll(needle)); }
private Collection4 Range(int end) { Collection4 range = new Collection4(); for (int i = 0; i < end; ++i) { range.Add(i); } return range; }
public static Collection4 AsList(object[] arr) { var coll = new Collection4(); for (var arrIdx = 0; arrIdx < arr.Length; arrIdx++) { coll.Add(arr[arrIdx]); } return coll; }