Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ FindItemIndex()

int System.Collections.Generic.HashSet< T >.FindItemIndex ( T item)
inlineprivate

Definition at line 248 of file HashSet.cs.

249 {
250 int[] buckets = _buckets;
251 if (buckets != null)
252 {
254 uint num = 0u;
255 IEqualityComparer<T> comparer = _comparer;
256 if (comparer == null)
257 {
258 int num2 = item?.GetHashCode() ?? 0;
259 if (typeof(T).IsValueType)
260 {
261 int num3 = GetBucketRef(num2) - 1;
262 while (num3 >= 0)
263 {
265 if (reference.HashCode == num2 && EqualityComparer<T>.Default.Equals(reference.Value, item))
266 {
267 return num3;
268 }
269 num3 = reference.Next;
270 num++;
271 if (num > (uint)entries.Length)
272 {
273 ThrowHelper.ThrowInvalidOperationException_ConcurrentOperationsNotSupported();
274 }
275 }
276 }
277 else
278 {
279 EqualityComparer<T> @default = EqualityComparer<T>.Default;
280 int num4 = GetBucketRef(num2) - 1;
281 while (num4 >= 0)
282 {
284 if (reference2.HashCode == num2 && @default.Equals(reference2.Value, item))
285 {
286 return num4;
287 }
288 num4 = reference2.Next;
289 num++;
290 if (num > (uint)entries.Length)
291 {
292 ThrowHelper.ThrowInvalidOperationException_ConcurrentOperationsNotSupported();
293 }
294 }
295 }
296 }
297 else
298 {
299 int num5 = ((item != null) ? comparer.GetHashCode(item) : 0);
300 int num6 = GetBucketRef(num5) - 1;
301 while (num6 >= 0)
302 {
304 if (reference3.HashCode == num5 && comparer.Equals(reference3.Value, item))
305 {
306 return num6;
307 }
308 num6 = reference3.Next;
309 num++;
310 if (num > (uint)entries.Length)
311 {
312 ThrowHelper.ThrowInvalidOperationException_ConcurrentOperationsNotSupported();
313 }
314 }
315 }
316 }
317 return -1;
318 }
IEqualityComparer< T > _comparer
Definition HashSet.cs:105
ref int GetBucketRef(int hashCode)
Definition HashSet.cs:321

References System.Collections.Generic.HashSet< T >._buckets, System.Collections.Generic.HashSet< T >._comparer, System.Collections.Generic.HashSet< T >._entries, System.comparer, System.Runtime.Serialization.Dictionary, System.Collections.Generic.HashSet< T >.GetBucketRef(), System.item, and System.ThrowHelper.ThrowInvalidOperationException_ConcurrentOperationsNotSupported().

Referenced by System.Collections.Generic.HashSet< T >.AddIfNotPresent(), System.Collections.Generic.HashSet< T >.CheckUniqueAndUnfoundElements(), System.Collections.Generic.HashSet< T >.Contains(), System.Collections.Generic.HashSet< T >.IntersectWithEnumerable(), and System.Collections.Generic.HashSet< T >.TryGetValue().