Exemplo n.º 1
0
 public OrderedEnumerator(SequencedHashMap parent, ReturnType returnType)
 {
     _parent           = parent;
     _returnType       = returnType;
     _pos              = _parent._sentinel;
     _expectedModCount = _parent._modCount;
 }
		public void SetUp() 
		{
			_shm = new SequencedHashMap();
			_emptyShm = new SequencedHashMap();

			_expectedKeys = new ArrayList();
			_expectedKeys.Add("test1"); 
			_expectedKeys.Add("test2"); 
			_expectedKeys.Add("test3");

			_expectedValues = new ArrayList();
			_expectedValues.Add(1); 
			_expectedValues.Add("2"); 
			_expectedValues.Add(true);

			for (int i=0; i<_expectedKeys.Count; i++) 
			{
				_shm[_expectedKeys[i]] = _expectedValues[i];
			}
		}
Exemplo n.º 3
0
 public ValuesCollection(SequencedHashMap parent)
 {
     _parent = parent;
 }
Exemplo n.º 4
0
 public KeyCollection(SequencedHashMap parent)
 {
     _parent = parent;
 }
			public OrderedEnumerator(SequencedHashMap parent, ReturnType returnType)
			{
				_parent = parent;
				_returnType = returnType;
				_pos = _parent._sentinel;
				_expectedModCount = _parent._modCount;
			}
			public ValuesCollection(SequencedHashMap parent)
			{
				_parent = parent;
			}
			public KeyCollection(SequencedHashMap parent)
			{
				_parent = parent;
			}
		//[Test]
		// User should uncomment if they want to see the Performance Comparison
		public void Performance() 
		{
			// set the hashtable and SequencedHashMap to be the 
			IDictionary hashtable;
			IDictionary sequenced;
			IDictionary list;

			int numOfRuns = 1;

			int numOfEntries = Int16.MaxValue;

			long hashStart;
			long[] hashPopulateTicks = new long[numOfRuns];
			long[] hashItemTicks = new long[numOfRuns];

			long seqStart;
			long[] seqPopulateTicks = new long[numOfRuns];
			long[] seqItemTicks = new long[numOfRuns];

			long listStart;
			long[] listPopulateTicks = new long[numOfRuns];
			long[] listItemTicks = new long[numOfRuns];

			for (int runIndex = 0; runIndex < numOfRuns; runIndex++) 
			{
				object key;
				object value;
				hashtable = new Hashtable();
				sequenced = new SequencedHashMap();
				list = new System.Collections.Specialized.ListDictionary();

				hashStart = DateTime.Now.Ticks;

				for(int i = 0; i < numOfEntries; i++) 
				{
					hashtable.Add("test" + i, new object());
				}

				hashPopulateTicks[runIndex] = DateTime.Now.Ticks - hashStart;

				hashStart = DateTime.Now.Ticks;
				for(int i = 0; i < numOfEntries; i++) 
				{
					key = "test" + i;
					value = hashtable[key];
				}

				hashItemTicks[runIndex] = DateTime.Now.Ticks - hashStart;

				hashtable.Clear();

				seqStart = DateTime.Now.Ticks;

				for(int i = 0; i < numOfEntries; i++) 
				{
					sequenced.Add("test" + i, new object());
				}

				seqPopulateTicks[runIndex] = DateTime.Now.Ticks - seqStart;

				seqStart = DateTime.Now.Ticks;
				for(int i = 0; i < numOfEntries; i++) 
				{
					key = "test" + i;
					value = sequenced[key];
				}

				seqItemTicks[runIndex] = DateTime.Now.Ticks - seqStart;

				sequenced.Clear();

				listStart = DateTime.Now.Ticks;

				for(int i = 0; i < numOfEntries; i++) 
				{
					list.Add("test" + i, new object());
				}

				listPopulateTicks[runIndex] = DateTime.Now.Ticks - listStart;

				listStart = DateTime.Now.Ticks;
				for(int i = 0; i < numOfEntries; i++) 
				{
					key = "test" + i;
					value = list[key];
				}

				listItemTicks[runIndex] = DateTime.Now.Ticks - listStart;


				list.Clear();

			}
			
			for (int runIndex = 0; runIndex < numOfRuns; runIndex++) 
			{
				decimal seqPopulateOverhead = ( (decimal)seqPopulateTicks[runIndex] /(decimal)hashPopulateTicks[runIndex] );
				decimal seqItemOverhead = ( (decimal)seqItemTicks[runIndex] / (decimal)hashItemTicks[runIndex] );

				string errMessage = "SequenceHashMap vs Hashtable:";
				errMessage += "\n POPULATE:";
				errMessage += "\n\t seqPopulateTicks[" + runIndex + "] took " + seqPopulateTicks[runIndex] + " ticks.";
				errMessage += "\n\t hashPopulateTicks[" + runIndex + "] took " + hashPopulateTicks[runIndex] + " ticks.";
				errMessage += "\n\t for an overhead of " + seqPopulateOverhead .ToString() ;
				errMessage += "\n ITEM:";
				errMessage += "\n\t seqItemTicks[" + runIndex + "] took " + seqItemTicks[runIndex] + " ticks.";
				errMessage += "\n\t hashItemTicks[" + runIndex + "] took " + hashItemTicks[runIndex] + " ticks.";
				errMessage += "\n\t for an overhead of " + seqItemOverhead .ToString() ;
				
				System.Console.Out.WriteLine(errMessage);
				
				decimal listPopulateOverhead = ( (decimal)listPopulateTicks[runIndex] / (decimal)seqPopulateTicks[runIndex] );
				decimal listItemOverhead = ( (decimal)listItemTicks[runIndex] / (decimal)seqItemTicks[runIndex] );

				errMessage = "ListDictionary vs SequenceHashMap:";
				errMessage += "\n POPULATE:";
				errMessage += "\n\t listPopulateTicks[" + runIndex + "] took " + listPopulateTicks[runIndex] + " ticks.";
				errMessage += "\n\t seqPopulateTicks[" + runIndex + "] took " + seqPopulateTicks[runIndex] + " ticks.";
				errMessage += "\n\t for an overhead of " + listPopulateOverhead.ToString();
				errMessage += "\n ITEM:";
				errMessage += "\n\t listItemTicks[" + runIndex + "] took " + listItemTicks[runIndex] + " ticks.";
				errMessage += "\n\t seqItemTicks[" + runIndex + "] took " + seqItemTicks[runIndex] + " ticks.";
				errMessage += "\n\t for an overhead of " + listItemOverhead .ToString() ;
				
				System.Console.Out.WriteLine(errMessage);

			}
		}
		public void Values() 
		{
			int i=0;
			foreach(object obj in _shm.Values) 
			{
				i++;
				Assert.IsTrue( _expectedValues.Contains(obj) );
			}

			Assert.AreEqual(3, i);

			SequencedHashMap empty = new SequencedHashMap();
			foreach(object obj in empty.Values) 
			{
				Assert.Fail("should not be a value:" + obj);
			}
		}
Exemplo n.º 10
0
		/// <summary>
		/// Set a type name for specified type key and capacity
		/// </summary>
		/// <param name="typecode">the type key</param>
		/// <param name="capacity">the (maximum) type size/length</param>
		/// <param name="value">The associated name</param>
		public void Put( DbType typecode, int capacity, string value )
		{
			SequencedHashMap map = weighted[ typecode ] as SequencedHashMap;
			if( map == null )
			{
				weighted[ typecode ] = map = new SequencedHashMap();
			}
			map[ capacity ] = value;
		}
Exemplo n.º 11
0
		internal static IDictionary GetParameterTypes(XmlNode queryElem)
		{
			IDictionary result = new SequencedHashMap();
			foreach (XmlElement element in queryElem.SelectNodes(HbmConstants.nsQueryParam, nsmgr))
			{
				result[XmlHelper.GetAttributeValue(element, "name")] = XmlHelper.GetAttributeValue(element, "type");
			}
			return result;
		}