getting keyspace in between objects numbers that store in vectors or maps

i have a fix number of vectors object to store. Each have a private variable key number in it. lets say i have 40 objects. my objects from 0-39 works like a clock. The clockwise direction next to 39 would be 0.

If all of the objects are remove except number 7,14 and 38 objects. how can i calculate the keyspace between 38 - 7. i should get 39,40,1,2,3,4,5,6 and 7. anyone can help me? or should i change my vector to other containers? any container or formula to solve this problem?
Topic archived. No new replies allowed.