/** * Creates a new SplitNode. * @param access the access to the owner of this node. Must not be <code>null</code> * @param id the unique id of this node, -1 indicates that the id must be created */ protected SplitNode( SplitDockAccess access, long id ){ if( access == null ) throw new IllegalArgumentException( "Access must not be null" ); this.access = access; if( id < 0 ) this.id = access.uniqueID(); else this.id = id; }
private int ensureIdUnique( long[] ids, int offset ){ idChecked = true; int delta = 0; ids[offset] = getId(); offset++; for( int i = 0, n = getMaxChildrenCount(); i<n; i++ ){ SplitNode child = getChild( i ); if( child != null ){ delta += child.ensureIdUnique( ids, offset + delta ); } } boolean issue = true; while( issue ){ issue = false; long id = getId(); for( int i = 0; i < delta; i++ ){ if( ids[offset+i] == id ){ this.id = access.uniqueID(); issue = true; break; } } } return delta + 1; }