private void doPut(E kkey){
  Comparable<? super E> key=comparable(kkey);
  for (; ; ) {
    Node<E> b=findPredecessor(key);
    Node<E> n=b.next;
    for (; ; ) {
      if (n != null) {
        Node<E> f=n.next;
        if (n != b.next)         break;
        Object v=n.value;
        if (v == null) {
          n.helpDelete(b,f);
          break;
        }
        if (v == n || b.value == null)         break;
        int c=key.compareTo(n.key);
        if (c >= 0) {
          b=n;
          n=f;
          continue;
        }
      }
      Node<E> z=new Node<E>(kkey,n);
      if (!b.casNext(n,z))       break;
      int level=randomLevel();
      if (level > 0)       insertIndex(z,level);
      return;
    }
  }
}

private void doPut ( E kkey ) { Comparable < ? super E > key = comparable ( kkey ) ; for ( ; ; ) { Node < E > b = findPredecessor ( key ) ; Node < E > n = b . next ; for ( ; ; ) { if ( n != null ) { Node < E > f = n . next ; if ( n != b . next ) break ; Object v = n . value ; if ( v == null ) { n . helpDelete ( b , f ) ; break ; } if ( v == n || b . value == null ) break ; int c = key . compareTo ( n . key ) ; if ( c >= 0 ) { b = n ; n = f ; continue ; } } Node < E > z = new Node < E > ( kkey , n ) ; if ( ! b . casNext ( n , z ) ) break ; int level = randomLevel ( ) ; if ( level > 0 ) insertIndex ( z , level ) ; return ; } } }
main insertion method . adds element if not present , or replaces value if present and onlyifabsent is false .
