package InventoryIterator public class InventoryIterator unit u int nextSlot // points to the slot id which holds the next item, 6 if none construct(unit u) this.u = u this.nextSlot = -1 private function findNextNonemptySlot() while(nextSlot < 6 and UnitItemInSlot(u, nextSlot+1) == null) nextSlot++ function hasNext() returns boolean findNextNonemptySlot() return nextSlot < 6 function next() returns item nextSlot++ return UnitItemInSlot(u, nextSlot) function getCurrentSlotId() returns int return nextSlot function close() destroy this