org.miv.pherd.ntree.util
Class NTreeLevels

java.lang.Object
  extended by org.miv.pherd.ntree.util.NTreeLevels

public class NTreeLevels
extends Object

Levels in a NTree.

The levels represent sets of cells that are all at a given depth. They are automatically updated when you use the CellLevelData class as data for the cells of your tree.

When you use the CellLevelData as data of your cells, they automatically maintain the cell level in an instance of this class. This instance can then be queried to browse cells by levels.

Since:
2007
Author:
Antoine Dutot

Field Summary
protected  ArrayList<HashSet<Cell>> levels
          The levels.
 
Constructor Summary
NTreeLevels()
           
 
Method Summary
protected  void check(Cell cell)
          Called by a CellLevelData instance to check it is correctly registered in its level.
 Set<? extends Cell> getLevel(int i)
          Set of cells of the i-th level.
 int getLevelCount()
          The number of levels in the tree (equals to the depth of the tree).
protected  void trim()
          Remove empty levels at the top of the level stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

levels

protected ArrayList<HashSet<Cell>> levels
The levels. Each level is a set of cells.

Constructor Detail

NTreeLevels

public NTreeLevels()
Method Detail

getLevelCount

public int getLevelCount()
The number of levels in the tree (equals to the depth of the tree).

Returns:
The number of levels.

getLevel

public Set<? extends Cell> getLevel(int i)
Set of cells of the i-th level.

Parameters:
i - The level.
Returns:
A set of cells (maybe empty).

trim

protected void trim()
Remove empty levels at the top of the level stack.


check

protected void check(Cell cell)
Called by a CellLevelData instance to check it is correctly registered in its level.

Parameters:
cell - The cell to check.


Copyright © 2011. All Rights Reserved.