It's a custom binary heap: there's a maximum number of elements (the number of neighbors) and it throws out neighbors that are too far away.  It also performs the same swaps on both the indices and distances.