public void set ( E key , T value ) { Entry < E , T > entry = new Entry < E , T > ( key , value , null , null ) ; synchronized ( this ) { if ( map . get ( key ) == null ) { if ( this . length >= this . capacity ) this . removeLeastUsedElements ( ) ; entry . prev = this . head ; entry . next = this . head . next ; this . head . next . prev = entry ; this . head . next = entry ; this . length ++ ; map . put ( key , entry ) ; } else { entry = map . get ( key ) ; entry . value = value ; entry . prev . next = entry . next ; entry . next . prev = entry . prev ; entry . prev = this . head ; entry . next = this . head . next ; this . head . next . prev = entry ; this . head . next = entry ; } } }
set a element to list