I am trying to figure out how to determine whether all values in a Table are empty.
starting graph: {1: @[0], 2: @[1, 6], 3: @[2], 4: @[2], 5: @[4], 6: @[5, 8], 7: @[9], 8: @[7], 9: @[6], 0: @[3]}
I delete a value after doing something for several iterations. I stop deleting values when a condition is met. This means that how many values I delete, and whether they are all deleted is random.
My result looks something like this after reaching my condition:
new graph after del: {1: @[], 2: @[], 3: @[], 4: @[], 5: @[], 6: @[8], 7: @[9], 8: @[7], 9: @[6], 0: @[]}
I want to continue iterating until all values are empty (so basically should look like this when I have a correct answer):
new graph after del all: {1: @[], 2: @[], 3: @[], 4: @[], 5: @[], 6: @[], 7: @[], 8: @[], 9: @[], 0: @[]}
What is the appropriate way to check if all values in a Table are empty or == @[]?
Note, when your keys are integers you may consider using a seq or array for your objects, especially when keys are am continues range. That may be more efficient.
What you now use is a hash table with keys as int and seq as values, but you seems not to delete the entries when done, but you replace the values with empty seq. When you will delete instead of replacing with empty seq, you should finally get an empty table, so you get a done indicator automatically, as len table will become zero.
Finally, when you can not do it in this ways, you would have to iterate over table values with values or pairs iterator and check if all seqs are empty, but of course this is a very bad and slow solution.