How to find the first key with an empty value in a map?

I’m making an inventory system. The inventory is a map assigning a certain slot number to an item.

I can add items to a specified in the inventory. i.e put item x in slot 3.

Now I want to add an item to the first available slot. i.e slot 1-5 is taken, 7-9 is taken, 6 was never assigned and thus is empty. We should add item to that slot.

This has left me wondering, what value does a map hold when nothing is stored in its value? null? Is there a simpler way of doing this than to find every key and checking to see if it equals null or w.e?

I realized isvalid could be used to give a boolean that i could determine from instead of having to read the actual value

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.