@ Override public TreeNode setSibling ( int index , TreeNode node ) { if ( node == null ) { throw new NullPointerException ( ) ; } else if ( ( index < 0 ) || ( index >= size ( ) ) ) { throw new IndexOutOfBoundsException ( ) ; } else { if ( ! parent . equals ( node . getParent ( ) ) ) { eraseParent ( node ) ; } TreeNode previous = get ( index ) ; super . set ( index , node ) ; node . setParent ( parent ) ; updateRowKeys ( parent ) ; updateSelectionState ( parent ) ; return previous ; } }
Optimized set implementation to be used in sorting