Array and fastloops. Array for placing items in the inventory, fastloops to check for empty spaces / items available to stack.

P.S I am making an RPG game and I will make an inventory soon.