コード例 #1
0
ファイル: Collection4TestCase.cs プロジェクト: masroore/db4o
 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));
 }
コード例 #2
0
		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;
		}
コード例 #3
0
ファイル: Collection4TestCase.cs プロジェクト: Galigator/db4o
		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));
		}
コード例 #4
0
ファイル: MapHandler.cs プロジェクト: superyfwy/db4o
		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();
		}
コード例 #5
0
		internal virtual void CacheDirty(Collection4 col)
		{
			if (!BitIsTrue(Const4.CachedDirty))
			{
				BitTrue(Const4.CachedDirty);
				col.Add(this);
			}
		}
コード例 #6
0
ファイル: ExcludingReflector.cs プロジェクト: Galigator/db4o
		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);
			}
		}
コード例 #7
0
ファイル: ExcludingReflector.cs プロジェクト: masroore/db4o
 public ExcludingReflector(Type[] excludedClasses)
 {
     _excludedClasses = new Collection4();
     for (var claxxIndex = 0; claxxIndex < excludedClasses.Length; ++claxxIndex)
     {
         var claxx = excludedClasses[claxxIndex];
         _excludedClasses.Add(claxx.FullName);
     }
 }
コード例 #8
0
ファイル: Arrays4.cs プロジェクト: pondyond/db4o
        public static Collection4 AsList(object[] arr)
        {
            var coll = new Collection4();

            for (var arrIdx = 0; arrIdx < arr.Length; arrIdx++)
            {
                coll.Add(arr[arrIdx]);
            }
            return(coll);
        }
コード例 #9
0
		private Collection4 Copy(IEnumerable subject)
		{
			Collection4 result = new Collection4();
			IEnumerator it = subject.GetEnumerator();
			while (it.MoveNext())
			{
				result.Add(it.Current);
			}
			return result;
		}
コード例 #10
0
ファイル: Collection4.cs プロジェクト: masroore/db4o
 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;
 }
コード例 #11
0
ファイル: Collection4.cs プロジェクト: danfma/db4o-net
        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);
        }
コード例 #12
0
 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();
 }
コード例 #13
0
ファイル: Collection4.cs プロジェクト: pondyond/db4o
        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);
        }
コード例 #14
0
ファイル: BlockingQueue.cs プロジェクト: pondyond/db4o
            public object Run()
            {
                _enclosing.UnsafeWaitForNext();
                var i = 0;

                while (_enclosing.HasNext())
                {
                    i++;
                    target.Add(_enclosing.UnsafeNext());
                }
                return(i);
            }
コード例 #15
0
		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);
		}
コード例 #16
0
        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());
        }
コード例 #17
0
 private void CollectKnownClass(Collection4 classes, IReflectClass clazz)
 {
     if (IsInternalClass(clazz))
     {
         return;
     }
     if (!HasIdentity(clazz))
     {
         return;
     }
     if (clazz.IsArray())
     {
         return;
     }
     classes.Add(clazz);
 }
コード例 #18
0
		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;
			}
		}
コード例 #19
0
ファイル: IteratorAssert.cs プロジェクト: superyfwy/db4o
		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());
		}
コード例 #20
0
 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;
 }
コード例 #21
0
ファイル: MCommittedInfo.cs プロジェクト: masroore/db4o
 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);
 }
コード例 #22
0
ファイル: Platform4.cs プロジェクト: superyfwy/db4o
		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);
                }
            }
        }
コード例 #23
0
ファイル: QCon.cs プロジェクト: Galigator/db4o
		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);
		}
コード例 #24
0
		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();
			}
		}
コード例 #25
0
		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();
		}
コード例 #26
0
		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;
		}
コード例 #27
0
			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();
			}
コード例 #28
0
		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();
		}
コード例 #29
0
		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();
		}
コード例 #30
0
		private void CollectLeavesFromJoinConstraint(Collection4 leaves, QCon constraint)
		{
			if (constraint is QConJoin)
			{
				CollectLeavesFromJoin(leaves, (QConJoin)constraint);
			}
			else
			{
				if (!leaves.ContainsByIdentity(constraint))
				{
					leaves.Add(constraint);
				}
			}
		}
コード例 #31
0
		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);
				}
			}
		}
コード例 #32
0
		/// <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()));
		}
コード例 #33
0
ファイル: Collection4TestCase.cs プロジェクト: Galigator/db4o
		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));
		}
コード例 #34
0
		private Collection4 Range(int end)
		{
			Collection4 range = new Collection4();
			for (int i = 0; i < end; ++i)
			{
				range.Add(i);
			}
			return range;
		}
コード例 #35
0
ファイル: Arrays4.cs プロジェクト: masroore/db4o
 public static Collection4 AsList(object[] arr)
 {
     var coll = new Collection4();
     for (var arrIdx = 0; arrIdx < arr.Length; arrIdx++)
     {
         coll.Add(arr[arrIdx]);
     }
     return coll;
 }