getHighestBlockAt Computational Complexity

Discussion in 'Bukkit Discussion' started by krisdestruction, Jul 4, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    krisdestruction

    Anyone know what the World.getHighestBlockAt() function's computational complexity is? Is it a O(1) or O(n) operation (where n is the total number of blocks in the vertical)? I wanted to compare the performance of this function versus just using Chunk.getBlock() and scanning for the highest non-air block.
     
  2. Offline

    Jogy34

    The bukkit method makes sure the chunk is loaded then goes into the NMS WorldServer object which retrieves the chunk if it is loaded (which is why bukkit loads it) and then goes into that chunk which contains a height map and just gets the value from there. So... yeah, the bukkit method is more efficient than just iterating through the blocks.
     
    krisdestruction likes this.
  3. Offline

    krisdestruction

    Thanks, so it is a O(1) operation after all. I'll keep that in mind!
     
Thread Status:
Not open for further replies.

Share This Page