At construction it is configured with how the snapshots should be organized into buckets. How many and the space in time between them.
It is then updated with the current layout on the storage medium.
The only data that it relies on is the basename of the paths that are pushed to it.
It operates on two passes. During the first pass snapshots are added to the buckets following a best fit algorithm. Snapshots are never discarded at this stage. If a snapshot do not fit in a bucket or is replaced it is moved to a waiting list.
During the second pass the waiting snapshots are mapped back to the buckets via the same best fit algorithm. The difference here is that the buckets "time" is matched against all waiting snapshots. This is the reverse of the first pass.
Pass two. Moving waiting to either buckets or discarded.
Snapshots that has been discarded because they do are not the best fit for any bucket.
Based on the first pass of the algoritm.
The time of the bucket which a snapshot should try to match.
Snapshots collected for pass two.