當前位置: 首頁>>代碼示例>>C#>>正文


C# Statement.GetHashCode方法代碼示例

本文整理匯總了C#中SemWeb.Statement.GetHashCode方法的典型用法代碼示例。如果您正苦於以下問題:C# Statement.GetHashCode方法的具體用法?C# Statement.GetHashCode怎麽用?C# Statement.GetHashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SemWeb.Statement的用法示例。


在下文中一共展示了Statement.GetHashCode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Find

		private int Find (Statement key)
		{
			Slot [] table = this.table;
			uint size = (uint) table.Length;
			int h = key.GetHashCode() & Int32.MaxValue;
			uint indx = (uint)h;
			uint step = (uint) ((h >> 5)+1) % (size-1)+1;
			
			for (uint i = size; i > 0; i--) {
				indx %= size;
				Slot entry = table [indx];
				if (!entry.used)
					break;
				
				Statement k = entry.key;
				
				if ((entry.hashMix & Int32.MaxValue) == h
				    && k == key) {
					return (int) indx;
				}

				if ((entry.hashMix & CHAIN_MARKER) == 0)
					break;

				indx += step;
			}
			return -1;
		}
開發者ID:AminBonyadUni,項目名稱:facedetect-f-spot,代碼行數:28,代碼來源:Util.cs

示例2: PutImpl

		private void PutImpl (Statement key, Object value, bool overwrite)
		{
			uint size = (uint)this.table.Length;
			if (this.inUse >= this.threshold) {
				this.Rehash ();
				size = (uint)this.table.Length;
			}

			int h = key.GetHashCode() & Int32.MaxValue;
			uint spot = (uint)h;
			uint step = (uint) ((spot>>5)+1)% (size-1)+1;
			Slot [] table = this.table;
			Slot entry;

			int freeIndx = -1;
			for (int i = 0; i < size; i++) {
				int indx = (int) (spot % size);
				entry = table [indx];

				if (freeIndx == -1
				    && entry.removed
				    && (entry.hashMix & CHAIN_MARKER) != 0)
					freeIndx = indx;

				if (!entry.used ||
				    (entry.removed
				     && (entry.hashMix & CHAIN_MARKER) == 0)) {

					if (freeIndx == -1)
						freeIndx = indx;
					break;
				}

				if ((entry.hashMix & Int32.MaxValue) == h && key == entry.key) {
					if (overwrite) {
						table [indx].value = value;
						++this.modificationCount;
					} else {
						// Handle Add ():
						// An entry with the same key already exists in the Hashtable.
						throw new ArgumentException (
								"Key duplication when adding: " + key);
					}
					return;
				}

				if (freeIndx == -1) {
					table [indx].hashMix |= CHAIN_MARKER;
				}

				spot+= step;

			}

			if (freeIndx!= -1) {
				table [freeIndx].used = true;
				table [freeIndx].removed = false;
				table [freeIndx].key = key;
				table [freeIndx].value = value;
				table [freeIndx].hashMix |= h;

				++this.inUse;
				++this.modificationCount;
			}

		}
開發者ID:AminBonyadUni,項目名稱:facedetect-f-spot,代碼行數:66,代碼來源:Util.cs

示例3:

		public Object this [Statement key] {
			get {
				Slot [] table = this.table;
				uint size = (uint) table.Length;
				int h = key.GetHashCode() & Int32.MaxValue;
				uint indx = (uint)h;
				uint step = (uint) ((h >> 5)+1) % (size-1)+1;
				
				for (uint i = size; i > 0; i--) {
					indx %= size;
					Slot entry = table [indx];
					if (!entry.used)
						break;
					
					Statement k = entry.key;
					
					if ((entry.hashMix & Int32.MaxValue) == h
					    && k == key) {
						return entry.value;
					}
	
					if ((entry.hashMix & CHAIN_MARKER) == 0)
						break;
	
					indx += step;
				}
				
				return null;
			}
			
			set {
				PutImpl (key, value, true);
			}
		}
開發者ID:AminBonyadUni,項目名稱:facedetect-f-spot,代碼行數:34,代碼來源:Util.cs


注:本文中的SemWeb.Statement.GetHashCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。