本文整理汇总了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;
}
示例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;
}
}
示例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);
}
}