public Node < E > append ( E value , int maxSize ) { Node < E > newTail = new Node <> ( randomLevel ( ) , value ) ; lock . writeLock ( ) . lock ( ) ; try { if ( size >= maxSize ) return null ; size ++ ; Node < E > tail = head ; for ( int i = maxHeight - 1 ; i >= newTail . height ( ) ; i -- ) { Node < E > next ; while ( ( next = tail . next ( i ) ) != null ) tail = next ; tail . size [ i ] ++ ; } for ( int i = newTail . height ( ) - 1 ; i >= 0 ; i -- ) { Node < E > next ; while ( ( next = tail . next ( i ) ) != null ) tail = next ; tail . setNext ( i , newTail ) ; newTail . setPrev ( i , tail ) ; } return newTail ; } finally { lock . writeLock ( ) . unlock ( ) ; } }
regardless of its future position in the list from other modifications