protected V RemoveEntryForKey(Key1 key1, Key2 key2, Key3 key3) { int hash = Hash(ExtractHash(key1, key2, key3)); Tuple3KeyEntry <Key1, Key2, Key3, V>[] table = this.table; int i = hash & (table.Length - 1); Tuple3KeyEntry <Key1, Key2, Key3, V> entry = table[i]; if (entry != null) { if (EqualKeys(key1, key2, key3, entry)) { table[i] = entry.GetNextEntry(); V value = entry.GetValue(); EntryRemoved(entry); return(value); } Tuple3KeyEntry <Key1, Key2, Key3, V> prevEntry = entry; entry = entry.GetNextEntry(); while (entry != null) { if (EqualKeys(key1, key2, key3, entry)) { prevEntry.SetNextEntry(entry.GetNextEntry()); V value = entry.GetValue(); EntryRemoved(entry); return(value); } prevEntry = entry; entry = entry.GetNextEntry(); } } return(default(V)); }
protected V SetValueForEntry(Tuple3KeyEntry <Key1, Key2, Key3, V> entry, V value) { V oldValue = entry.GetValue(); entry.SetValue(value); return(oldValue); }
public V Put(Key1 key1, Key2 key2, Key3 key3, V value) { int hash = Hash(ExtractHash(key1, key2, key3)); Tuple3KeyEntry <Key1, Key2, Key3, V>[] table = this.table; int i = hash & (table.Length - 1); Tuple3KeyEntry <Key1, Key2, Key3, V> entry = table[i]; while (entry != null) { if (EqualKeys(key1, key2, key3, entry)) { if (IsSetValueForEntryAllowed()) { return(SetValueForEntry(entry, value)); } V oldValue = entry.GetValue(); RemoveEntryForKey(key1, key2, key3); AddEntry(hash, key1, key2, key3, value, i); return(oldValue); } entry = entry.GetNextEntry(); } AddEntry(hash, key1, key2, key3, value, i); return(default(V)); }
public bool RemoveIfValue(Key1 key1, Key2 key2, Key3 key3, V value) { int hash = Hash(ExtractHash(key1, key2, key3)); Tuple3KeyEntry <Key1, Key2, Key3, V>[] table = this.table; int i = hash & (table.Length - 1); Tuple3KeyEntry <Key1, Key2, Key3, V> entry = table[i]; if (entry != null) { if (EqualKeys(key1, key2, key3, entry)) { table[i] = entry.GetNextEntry(); V existingValue = entry.GetValue(); if (!Object.ReferenceEquals(existingValue, value)) // Test if reference identical { return(false); } EntryRemoved(entry); return(true); } Tuple3KeyEntry <Key1, Key2, Key3, V> prevEntry = entry; entry = entry.GetNextEntry(); while (entry != null) { if (EqualKeys(key1, key2, key3, entry)) { prevEntry.SetNextEntry(entry.GetNextEntry()); V existingValue = entry.GetValue(); if (!Object.ReferenceEquals(existingValue, value)) // Test if reference identical { return(false); } EntryRemoved(entry); return(true); } prevEntry = entry; entry = entry.GetNextEntry(); } } return(false); }
public IList <V> Values() { Tuple3KeyEntry <Key1, Key2, Key3, V>[] table = this.table; List <V> valueList = new List <V>(Count); for (int a = table.Length; a-- > 0;) { Tuple3KeyEntry <Key1, Key2, Key3, V> entry = table[a]; while (entry != null) { valueList.Add(entry.GetValue()); entry = entry.GetNextEntry(); } } return(valueList); }
public V[] ToArray(V[] targetArray) { int index = 0; Tuple3KeyEntry <Key1, Key2, Key3, V>[] table = this.table; for (int a = table.Length; a-- > 0;) { Tuple3KeyEntry <Key1, Key2, Key3, V> entry = table[a]; while (entry != null) { targetArray[index++] = entry.GetValue(); entry = entry.GetNextEntry(); } } return(targetArray); }
public V Get(Key1 key1, Key2 key2, Key3 key3) { int hash = Hash(ExtractHash(key1, key2, key3)); Tuple3KeyEntry <Key1, Key2, Key3, V>[] table = this.table; int i = hash & (table.Length - 1); Tuple3KeyEntry <Key1, Key2, Key3, V> entry = table[i]; while (entry != null) { if (EqualKeys(key1, key2, key3, entry)) { return(entry.GetValue()); } entry = entry.GetNextEntry(); } return(default(V)); }
/** * @see java.util.Map#containsValue(java.lang.Object) */ public bool ContainsValue(V value) { Tuple3KeyEntry <Key1, Key2, Key3, V>[] table = this.table; if (value == null) { for (int a = table.Length; a-- > 0;) { Tuple3KeyEntry <Key1, Key2, Key3, V> entry = table[a]; while (entry != null) { Object entryValue = entry.GetValue(); if (entryValue == null) { return(true); } entry = entry.GetNextEntry(); } } } else { for (int a = table.Length; a-- > 0;) { Tuple3KeyEntry <Key1, Key2, Key3, V> entry = table[a]; while (entry != null) { Object entryValue = entry.GetValue(); if (value.Equals(entryValue)) { return(true); } entry = entry.GetNextEntry(); } } } return(false); }