A bidirectional array search algorithm for inventory equip index in games-- using loops and maps for optimal speed. Find the next or first valid item closest to the current in an array of any size.
https://dev.epicgames.com/community/learning/tutorials/DdM1/unreal-engine-dynamic-inventory-array-search-algorithm