Arthus
Arthus
CC#
Created by HD-Fr0sT on 1/14/2024 in #help
How do i exit this loop inside a loop
while(true){if(something)break;}
while(true){if(something)break;}
10 replies
CC#
Created by HD-Fr0sT on 1/14/2024 in #help
How do i exit this loop inside a loop
As a sugestion if you are trying to break the loop by a condition (done variable in your case) instead of break use continue;. If you will break, just don't have any condition
10 replies
CC#
Created by HD-Fr0sT on 1/14/2024 in #help
How do i exit this loop inside a loop
Nice, in the first scenario I understand it didn't hit the break. As you understand the break works perfectly so if it's not breaking the loop is because it wasn't hit it him.
10 replies
CC#
Created by turner on 1/14/2024 in #help
Dictionary cant find via ContainsKey but it does exist
If the Tkey in your case CilInstruction has an implemented IEqualityComparer, I understood you toldme they have a custom one, it will use the customComparer (which I understand it works properly)
10 replies
CC#
Created by turner on 1/14/2024 in #help
Dictionary cant find via ContainsKey but it does exist
Without debbugging will be hard to find. This is what ContainsKey will execute:
//some parsing and code for ValueTypes comparison
Debug.Assert(comparer is not null);
uint hashCode = (uint)comparer.GetHashCode(key);
int i = GetBucket(hashCode);
Entry[]? entries = _entries;
uint collisionCount = 0;
i--; // Value in _buckets is 1-based; subtract 1 from i. We do it here so it fuses with the following conditional.
do
{
// Should be a while loop https://github.com/dotnet/runtime/issues/9422
// Test in if to drop range check for following array access
if ((uint)i >= (uint)entries.Length)
{
goto ReturnNotFound;
}

entry = ref entries[i];
if (entry.hashCode == hashCode && comparer.Equals(entry.key, key))
{
goto ReturnFound;
}

i = entry.next;

collisionCount++;
} while (collisionCount <= (uint)entries.Length);

// The chain of entries forms a loop; which means a concurrent update has happened.
// Break out of the loop and throw, rather than looping forever.
goto ConcurrentOperation;
//some parsing and code for ValueTypes comparison
Debug.Assert(comparer is not null);
uint hashCode = (uint)comparer.GetHashCode(key);
int i = GetBucket(hashCode);
Entry[]? entries = _entries;
uint collisionCount = 0;
i--; // Value in _buckets is 1-based; subtract 1 from i. We do it here so it fuses with the following conditional.
do
{
// Should be a while loop https://github.com/dotnet/runtime/issues/9422
// Test in if to drop range check for following array access
if ((uint)i >= (uint)entries.Length)
{
goto ReturnNotFound;
}

entry = ref entries[i];
if (entry.hashCode == hashCode && comparer.Equals(entry.key, key))
{
goto ReturnFound;
}

i = entry.next;

collisionCount++;
} while (collisionCount <= (uint)entries.Length);

// The chain of entries forms a loop; which means a concurrent update has happened.
// Break out of the loop and throw, rather than looping forever.
goto ConcurrentOperation;
Looking at you code and so far seems to be that the issue is on runtime so I can't go any further without debugging. I will sugest write a test and reproduce it
10 replies
CC#
Created by turner on 1/14/2024 in #help
Dictionary cant find via ContainsKey but it does exist
So far what I understood is:
var dictionary = new Dictionary<CilIntruction,int>() {somePairs};

var yourLookupKey = //initialization;

Debug.Assert(dictionary.ContainsKey(yourLookupKey) == true); //Here throws
var dictionary = new Dictionary<CilIntruction,int>() {somePairs};

var yourLookupKey = //initialization;

Debug.Assert(dictionary.ContainsKey(yourLookupKey) == true); //Here throws
10 replies
CC#
Created by turner on 1/14/2024 in #help
Dictionary cant find via ContainsKey but it does exist
What I want to see if how you hidratate your Dictionary and where are you trying to do the ContainsKey so I can see if your are doing something wrong
10 replies
CC#
Created by turner on 1/14/2024 in #help
Dictionary cant find via ContainsKey but it does exist
Hello, can you share a bit more about your code? Remember that the ContainsKey will use Object.Equals to find you key in the dictionary.
10 replies
CC#
Created by HD-Fr0sT on 1/14/2024 in #help
How do i exit this loop inside a loop
Hello, I undestand you infinite loop is the do-while() loop. In order to break the parent loop you can either break it or have a condition to break it i.e Console.ReadKey() == ConsoleKey.Escape or a CancellationToken. Anyway there is missing information and context regarding what are you trying to do. Please give me more info so I could guide you
10 replies