Node < E > replace ( E newElement ) { for ( ; ; ) { Node < E > b = getPrev ( ) ; Node < E > f = getNext ( ) ; if ( b == null || f == null || f . isMarker ( ) ) return null ; Node < E > x = new Node < E > ( newElement , f , b ) ; if ( casNext ( f , new Node < E > ( x ) ) ) { b . successor ( ) ; // to relink b x . successor ( ) ; // to relink f return x ; } } }
Tries to insert a node holding element to replace this node . failing if already deleted . A currently unused proof of concept that demonstrates atomic node content replacement .