idx
int64 0
41.2k
| question
stringlengths 83
4.15k
| target
stringlengths 5
715
|
|---|---|---|
700
|
private void cleanLeftEdge ( int cutIndex ) { if ( cutIndex < ( 1 << 5 ) ) { zeroLeft ( pointer . display0 , cutIndex ) ; } else if ( cutIndex < ( 1 << 10 ) ) { zeroLeft ( pointer . display0 , cutIndex & 0x1f ) ; pointer . display1 = copyRight ( pointer . display1 , ( cutIndex >>> 5 ) ) ; } else if ( cutIndex < ( 1 << 15 ) ) { zeroLeft ( pointer . display0 , cutIndex & 0x1f ) ; pointer . display1 = copyRight ( pointer . display1 , ( cutIndex >>> 5 ) & 0x1f ) ; pointer . display2 = copyRight ( pointer . display2 , ( cutIndex >>> 10 ) ) ; } else if ( cutIndex < ( 1 << 20 ) ) { zeroLeft ( pointer . display0 , cutIndex & 0x1f ) ; pointer . display1 = copyRight ( pointer . display1 , ( cutIndex >>> 5 ) & 0x1f ) ; pointer . display2 = copyRight ( pointer . display2 , ( cutIndex >>> 10 ) & 0x1f ) ; pointer . display3 = copyRight ( pointer . display3 , ( cutIndex >>> 15 ) ) ; } else if ( cutIndex < ( 1 << 25 ) ) { zeroLeft ( pointer . display0 , cutIndex & 0x1f ) ; pointer . display1 = copyRight ( pointer . display1 , ( cutIndex >>> 5 ) & 0x1f ) ; pointer . display2 = copyRight ( pointer . display2 , ( cutIndex >>> 10 ) & 0x1f ) ; pointer . display3 = copyRight ( pointer . display3 , ( cutIndex >>> 15 ) & 0x1f ) ; pointer . display4 = copyRight ( pointer . display4 , ( cutIndex >>> 20 ) ) ; } else if ( cutIndex < ( 1 << 30 ) ) { zeroLeft ( pointer . display0 , cutIndex & 0x1f ) ; pointer . display1 = copyRight ( pointer . display1 , ( cutIndex >>> 5 ) & 0x1f ) ; pointer . display2 = copyRight ( pointer . display2 , ( cutIndex >>> 10 ) & 0x1f ) ; pointer . display3 = copyRight ( pointer . display3 , ( cutIndex >>> 15 ) & 0x1f ) ; pointer . display4 = copyRight ( pointer . display4 , ( cutIndex >>> 20 ) & 0x1f ) ; pointer . display5 = copyRight ( pointer . display5 , ( cutIndex >>> 25 ) ) ; } else { throw new IllegalArgumentException ( ) ; } }
|
requires structure is at index cutIndex and writable at level 0
|
701
|
@ SuppressWarnings ( "unchecked" ) public E getElem ( int index , int xor ) { if ( xor < ( 1 << 5 ) ) { return ( E ) display0 [ index & 31 ] ; } else if ( xor < ( 1 << 10 ) ) { return ( E ) ( ( Object [ ] ) display1 [ ( index >> 5 ) & 31 ] ) [ index & 31 ] ; } else if ( xor < ( 1 << 15 ) ) { return ( E ) ( ( Object [ ] ) ( ( Object [ ] ) display2 [ ( index >> 10 ) & 31 ] ) [ ( index >> 5 ) & 31 ] ) [ index & 31 ] ; } else if ( xor < ( 1 << 20 ) ) { return ( E ) ( ( Object [ ] ) ( ( Object [ ] ) ( ( Object [ ] ) display3 [ ( index >> 15 ) & 31 ] ) [ ( index >> 10 ) & 31 ] ) [ ( index >> 5 ) & 31 ] ) [ index & 31 ] ; } else if ( xor < ( 1 << 25 ) ) { return ( E ) ( ( Object [ ] ) ( ( Object [ ] ) ( ( Object [ ] ) ( ( Object [ ] ) display4 [ ( index >> 20 ) & 31 ] ) [ ( index >> 15 ) & 31 ] ) [ ( index >> 10 ) & 31 ] ) [ ( index >> 5 ) & 31 ] ) [ index & 31 ] ; } else if ( xor < ( 1 << 30 ) ) { return ( E ) ( ( Object [ ] ) ( ( Object [ ] ) ( ( Object [ ] ) ( ( Object [ ] ) ( ( Object [ ] ) display5 [ ( index >> 25 ) & 31 ] ) [ ( index >> 20 ) & 31 ] ) [ ( index >> 15 ) & 31 ] ) [ ( index >> 10 ) & 31 ] ) [ ( index >> 5 ) & 31 ] ) [ index & 31 ] ; } else { throw new IllegalArgumentException ( ) ; } }
|
requires structure is at pos oldIndex = xor ^ index
|
702
|
public void stabilize ( int index ) { switch ( depth - 1 ) { case 5 : display5 = copyOf ( display5 ) ; display4 = copyOf ( display4 ) ; display3 = copyOf ( display3 ) ; display2 = copyOf ( display2 ) ; display1 = copyOf ( display1 ) ; display5 [ ( index >> 25 ) & 31 ] = display4 ; display4 [ ( index >> 20 ) & 31 ] = display3 ; display3 [ ( index >> 15 ) & 31 ] = display2 ; display2 [ ( index >> 10 ) & 31 ] = display1 ; display1 [ ( index >> 5 ) & 31 ] = display0 ; break ; case 4 : display4 = copyOf ( display4 ) ; display3 = copyOf ( display3 ) ; display2 = copyOf ( display2 ) ; display1 = copyOf ( display1 ) ; display4 [ ( index >> 20 ) & 31 ] = display3 ; display3 [ ( index >> 15 ) & 31 ] = display2 ; display2 [ ( index >> 10 ) & 31 ] = display1 ; display1 [ ( index >> 5 ) & 31 ] = display0 ; break ; case 3 : display3 = copyOf ( display3 ) ; display2 = copyOf ( display2 ) ; display1 = copyOf ( display1 ) ; display3 [ ( index >> 15 ) & 31 ] = display2 ; display2 [ ( index >> 10 ) & 31 ] = display1 ; display1 [ ( index >> 5 ) & 31 ] = display0 ; break ; case 2 : display2 = copyOf ( display2 ) ; display1 = copyOf ( display1 ) ; display2 [ ( index >> 10 ) & 31 ] = display1 ; display1 [ ( index >> 5 ) & 31 ] = display0 ; break ; case 1 : display1 = copyOf ( display1 ) ; display1 [ ( index >> 5 ) & 31 ] = display0 ; break ; case 0 : break ; } }
|
ensures structure is clean and at pos index and writable at all levels except 0
|
703
|
public Object [ ] copyRange ( Object [ ] array , int oldLeft , int newLeft ) { Object [ ] elems = new Object [ 32 ] ; System . arraycopy ( array , oldLeft , elems , newLeft , 32 - Math . max ( newLeft , oldLeft ) ) ; return elems ; }
|
USED IN DROP
|
704
|
private void updateProgressButton ( ProgressButton progressButton , SeekBar progressSeekBar ) { progressButton . setProgress ( progressSeekBar . getProgress ( ) ) ; updatePinProgressContentDescription ( progressButton ) ; }
|
Helper method to update the progressButton s progress and it s content description .
|
705
|
private void updatePinProgressContentDescription ( ProgressButton button ) { int progress = button . getProgress ( ) ; if ( progress <= 0 ) { button . setContentDescription ( getString ( button . isChecked ( ) ? R . string . content_desc_pinned_not_downloaded : R . string . content_desc_unpinned_not_downloaded ) ) ; } else if ( progress >= button . getMax ( ) ) { button . setContentDescription ( getString ( button . isChecked ( ) ? R . string . content_desc_pinned_downloaded : R . string . content_desc_unpinned_downloaded ) ) ; } else { button . setContentDescription ( getString ( button . isChecked ( ) ? R . string . content_desc_pinned_downloading : R . string . content_desc_unpinned_downloading ) ) ; } }
|
Helper method to update the progressButton s content description .
|
706
|
private ProgressButton addProgressButton ( LinearLayout container ) { final LinearLayout . LayoutParams layoutParams = new LinearLayout . LayoutParams ( 0 , LinearLayout . LayoutParams . WRAP_CONTENT , 1.0f ) ; final ProgressButton progressButton = new ProgressButton ( this ) ; progressButton . setLayoutParams ( layoutParams ) ; container . addView ( progressButton ) ; return progressButton ; }
|
Helper function that creates a new progress button adds it to the given layout . Returns a reference to the progress button for customization .
|
707
|
public void setMax ( int max ) { if ( max <= 0 || max < mProgress ) { throw new IllegalArgumentException ( String . format ( "Max (%d) must be > 0 and >= %d" , max , mProgress ) ) ; } mMax = max ; invalidate ( ) ; }
|
Sets the maximum progress value . Defaults to 100 .
|
708
|
public void setProgressAndMax ( int progress , int max ) { if ( progress > max || progress < 0 ) { throw new IllegalArgumentException ( String . format ( "Progress (%d) must be between %d and %d" , progress , 0 , max ) ) ; } else if ( max <= 0 ) { throw new IllegalArgumentException ( String . format ( "Max (%d) must be > 0" , max ) ) ; } mProgress = progress ; mMax = max ; invalidate ( ) ; }
|
Sets the current progress and maximum progress value both of which must be valid values .
|
709
|
public void setMaxStrokeWidth ( float width ) { maxStrokeWidth = TypedValue . applyDimension ( TypedValue . COMPLEX_UNIT_DIP , width , getResources ( ) . getDisplayMetrics ( ) ) ; }
|
Sets the maximum stroke width
|
710
|
public void setMinStrokeWidth ( float width ) { minStrokeWidth = TypedValue . applyDimension ( TypedValue . COMPLEX_UNIT_DIP , width , getResources ( ) . getDisplayMetrics ( ) ) ; }
|
Sets the minimum stroke width
|
711
|
public void clear ( ) { if ( bitmap != null ) { bitmap . recycle ( ) ; } bitmap = Bitmap . createBitmap ( getWidth ( ) , getHeight ( ) , Bitmap . Config . ARGB_8888 ) ; canvas = new Canvas ( bitmap ) ; for ( InkListener listener : listeners ) { listener . onInkClear ( ) ; } invalidate ( ) ; isEmpty = true ; }
|
Clears the view
|
712
|
public Bitmap getBitmap ( int backgroundColor ) { Bitmap bitmap = Bitmap . createBitmap ( getWidth ( ) , getHeight ( ) , Bitmap . Config . ARGB_8888 ) ; Canvas bitmapCanvas = new Canvas ( bitmap ) ; if ( backgroundColor != 0 ) { bitmapCanvas . drawColor ( backgroundColor ) ; } bitmapCanvas . drawBitmap ( this . bitmap , 0 , 0 , null ) ; return bitmap ; }
|
Returns the bitmap of the drawing with the specified background color
|
713
|
public NonBlockingParser createNonBlockingParser ( SurfingConfiguration configuration ) { ensureSetting ( configuration ) ; return jsonParserAdapter . createNonBlockingParser ( new SurfingContext ( configuration ) ) ; }
|
Create non - blocking parser
|
714
|
public OrientGraphBaseFactory setupPool ( final int max ) { pool = new OPartitionedReCreatableDatabasePool ( this . factory , dbName , user , password , max ) ; return this ; }
|
Setting up the factory to use database pool instead of creation a new instance of database connection each time .
|
715
|
public void close ( ) { if ( pool != null ) pool . close ( ) ; pool = null ; if ( shouldCloseOrientDB ) { factory . close ( ) ; } }
|
Closes all pooled databases and clear the pool .
|
716
|
private Set < String > findClassLabelsInHasContainers ( ) { Set < String > classLabels = new HashSet < > ( ) ; HasContainer container = this . hasContainers . stream ( ) . filter ( hasContainer -> isLabelKey ( hasContainer . getKey ( ) ) ) . findFirst ( ) . orElseGet ( ( ) -> { String defaultClass = Vertex . class . isAssignableFrom ( getReturnClass ( ) ) ? "V" : "E" ; HasContainer defaultContainer = new HasContainer ( T . label . name ( ) , P . eq ( defaultClass ) ) ; return defaultContainer ; } ) ; Object value = container . getValue ( ) ; if ( value instanceof List ) { ( ( List ) value ) . forEach ( label -> classLabels . add ( ( String ) label ) ) ; } else { classLabels . add ( ( String ) value ) ; } return classLabels ; }
|
if one of the HasContainers is a label matching predicate then return those labels
|
717
|
private Iterator < Object > getValueIterator ( HasContainer c ) { return c . getPredicate ( ) . getBiPredicate ( ) == Contains . within ? ( ( Iterable < Object > ) c . getValue ( ) ) . iterator ( ) : IteratorUtils . of ( c . getValue ( ) ) ; }
|
gets the requested values from the Has step . If it s a single value wrap it in an array otherwise return the array
|
718
|
public void registerSensorManager ( int samplingPeriodUs ) { if ( getContext ( ) == null || mSensorManager != null ) return ; mSensorManager = ( SensorManager ) getContext ( ) . getSystemService ( Context . SENSOR_SERVICE ) ; if ( mSensorManager != null ) { mSensorManager . registerListener ( this , mSensorManager . getDefaultSensor ( Sensor . TYPE_ROTATION_VECTOR ) , samplingPeriodUs ) ; } }
|
Registers a sensor manager with the parallax ImageView . Should be called in onResume or onStart lifecycle callbacks from an Activity or Fragment .
|
719
|
public void unregisterSensorManager ( boolean resetTranslation ) { if ( mSensorManager == null || mSensorInterpreter == null ) return ; mSensorManager . unregisterListener ( this ) ; mSensorManager = null ; mSensorInterpreter . reset ( ) ; if ( resetTranslation ) { setTranslate ( 0 , 0 ) ; } }
|
Unregisters the ParallaxImageView s SensorManager . Should be called in onPause from an Activity or Fragment to avoid continuing sensor usage .
|
720
|
private void setTranslate ( float x , float y ) { if ( Math . abs ( x ) > 1 || Math . abs ( y ) > 1 ) { throw new IllegalArgumentException ( "Parallax effect cannot translate more than 100% of its off-screen size" ) ; } float xScale , yScale ; if ( mScaledIntensities ) { xScale = mXOffset ; yScale = mYOffset ; } else { xScale = Math . max ( mXOffset , mYOffset ) ; yScale = Math . max ( mXOffset , mYOffset ) ; } if ( mMaximumJump > 0 ) { if ( x - mXTranslation / xScale > mMaximumJump ) { x = mXTranslation / xScale + mMaximumJump ; } else if ( x - mXTranslation / xScale < - mMaximumJump ) { x = mXTranslation / xScale - mMaximumJump ; } if ( y - mYTranslation / yScale > mMaximumJump ) { y = mYTranslation / yScale + mMaximumJump ; } else if ( y - mYTranslation / yScale < - mMaximumJump ) { y = mYTranslation / yScale - mMaximumJump ; } } mXTranslation = x * xScale ; mYTranslation = y * yScale ; configureMatrix ( ) ; }
|
Sets the image view s translation coordinates . These values must be between - 1 and 1 representing the transaction percentage from the center .
|
721
|
private void configureMatrix ( ) { if ( getDrawable ( ) == null || getWidth ( ) == 0 || getHeight ( ) == 0 ) return ; int dWidth = getDrawable ( ) . getIntrinsicWidth ( ) ; int dHeight = getDrawable ( ) . getIntrinsicHeight ( ) ; int vWidth = getWidth ( ) ; int vHeight = getHeight ( ) ; float scale ; float dx , dy ; if ( dWidth * vHeight > vWidth * dHeight ) { scale = ( float ) vHeight / ( float ) dHeight ; mXOffset = ( vWidth - dWidth * scale * mParallaxIntensity ) * 0.5f ; mYOffset = ( vHeight - dHeight * scale * mParallaxIntensity ) * 0.5f ; } else { scale = ( float ) vWidth / ( float ) dWidth ; mXOffset = ( vWidth - dWidth * scale * mParallaxIntensity ) * 0.5f ; mYOffset = ( vHeight - dHeight * scale * mParallaxIntensity ) * 0.5f ; } dx = mXOffset + mXTranslation ; dy = mYOffset + mYTranslation ; mTranslationMatrix . set ( getImageMatrix ( ) ) ; mTranslationMatrix . setScale ( mParallaxIntensity * scale , mParallaxIntensity * scale ) ; mTranslationMatrix . postTranslate ( dx , dy ) ; setImageMatrix ( mTranslationMatrix ) ; }
|
Configures the ImageView s imageMatrix to allow for movement of the source image .
|
722
|
public static < T > MonadicObservableValue < T > monadic ( ObservableValue < T > o ) { if ( o instanceof MonadicObservableValue ) { return ( MonadicObservableValue < T > ) o ; } else { return new MonadicWrapper < > ( o ) ; } }
|
Creates a thin wrapper around an observable value to make it monadic .
|
723
|
public static String getDefaultMimeByExtension ( String filename ) { String type = null ; if ( filename != null ) { int i = - 1 ; while ( type == null ) { i = filename . indexOf ( "." , i + 1 ) ; if ( i < 0 || i >= filename . length ( ) ) break ; String ext = StringUtils . asciiToLowerCase ( filename . substring ( i + 1 ) ) ; type = __dftMimeMap . get ( ext ) ; } } if ( type == null ) { type = __dftMimeMap . get ( "*" ) ; } return type ; }
|
Get the MIME type by filename extension . Lookup only the static default mime map .
|
724
|
public static HttpURI createHttpURI ( String scheme , String host , int port , String path , String param , String query , String fragment ) { if ( port == 80 && HttpScheme . HTTP . is ( scheme ) ) port = 0 ; if ( port == 443 && HttpScheme . HTTPS . is ( scheme ) ) port = 0 ; return new HttpURI ( scheme , host , port , path , param , query , fragment ) ; }
|
Construct a normalized URI . Port is not set if it is the default port .
|
725
|
public static String encode ( MultiMap < String > map , Charset charset , boolean equalsForNullValue ) { if ( charset == null ) charset = ENCODING ; StringBuilder result = new StringBuilder ( 128 ) ; boolean delim = false ; for ( Map . Entry < String , List < String > > entry : map . entrySet ( ) ) { String key = entry . getKey ( ) ; List < String > list = entry . getValue ( ) ; int s = list . size ( ) ; if ( delim ) { result . append ( '&' ) ; } if ( s == 0 ) { result . append ( encodeString ( key , charset ) ) ; if ( equalsForNullValue ) result . append ( '=' ) ; } else { for ( int i = 0 ; i < s ; i ++ ) { if ( i > 0 ) result . append ( '&' ) ; String val = list . get ( i ) ; result . append ( encodeString ( key , charset ) ) ; if ( val != null ) { if ( val . length ( ) > 0 ) { result . append ( '=' ) ; result . append ( encodeString ( val , charset ) ) ; } else if ( equalsForNullValue ) result . append ( '=' ) ; } else if ( equalsForNullValue ) result . append ( '=' ) ; } } delim = true ; } return result . toString ( ) ; }
|
Encode MultiMap with % encoding .
|
726
|
public static void decode88591To ( InputStream in , MultiMap < String > map , int maxLength , int maxKeys ) throws IOException { synchronized ( map ) { StringBuffer buffer = new StringBuffer ( ) ; String key = null ; String value = null ; int b ; int totalLength = 0 ; while ( ( b = in . read ( ) ) >= 0 ) { switch ( ( char ) b ) { case '&' : value = buffer . length ( ) == 0 ? "" : buffer . toString ( ) ; buffer . setLength ( 0 ) ; if ( key != null ) { map . add ( key , value ) ; } else if ( value != null && value . length ( ) > 0 ) { map . add ( value , "" ) ; } key = null ; value = null ; if ( maxKeys > 0 && map . size ( ) > maxKeys ) throw new IllegalStateException ( String . format ( "Form with too many keys [%d > %d]" , map . size ( ) , maxKeys ) ) ; break ; case '=' : if ( key != null ) { buffer . append ( ( char ) b ) ; break ; } key = buffer . toString ( ) ; buffer . setLength ( 0 ) ; break ; case '+' : buffer . append ( ' ' ) ; break ; case '%' : int code0 = in . read ( ) ; int code1 = in . read ( ) ; buffer . append ( decodeHexChar ( code0 , code1 ) ) ; break ; default : buffer . append ( ( char ) b ) ; break ; } if ( maxLength >= 0 && ( ++ totalLength > maxLength ) ) throw new IllegalStateException ( String . format ( "Form with too many keys [%d > %d]" , map . size ( ) , maxKeys ) ) ; } if ( key != null ) { value = buffer . length ( ) == 0 ? "" : buffer . toString ( ) ; buffer . setLength ( 0 ) ; map . add ( key , value ) ; } else if ( buffer . length ( ) > 0 ) { map . add ( buffer . toString ( ) , "" ) ; } } }
|
Decoded parameters to MultiMap using ISO8859 - 1 encodings .
|
727
|
public InputStream getInputStream ( ) throws IOException , IllegalStateException { if ( this . read ) { throw new IllegalStateException ( "InputStream has already been read - " + "do not use InputStreamResource if a stream needs to be read multiple times" ) ; } this . read = true ; return this . inputStream ; }
|
This implementation throws IllegalStateException if attempting to read the underlying stream multiple times .
|
728
|
private < T > T createBean ( ResultSet rs , Class < T > type , PropertyDescriptor [ ] props , int [ ] columnToProperty ) throws SQLException { T bean = this . newInstance ( type ) ; return populateBean ( rs , bean , props , columnToProperty ) ; }
|
Creates a new object and initializes its fields from the ResultSet .
|
729
|
public < T > T populateBean ( ResultSet rs , T bean ) throws SQLException { Class < ? > type = bean . getClass ( ) ; PropertyDescriptor [ ] props = this . propertyDescriptors ( type ) ; int [ ] columnToProperty = this . mapColumnsToProperties ( rs . getMetaData ( ) , props , type ) ; return populateBean ( rs , bean , props , columnToProperty ) ; }
|
Initializes the fields of the provided bean from the ResultSet .
|
730
|
private < T > T populateBean ( ResultSet rs , T bean , PropertyDescriptor [ ] props , int [ ] columnToProperty ) throws SQLException { for ( int i = 1 ; i < columnToProperty . length ; i ++ ) { if ( columnToProperty [ i ] == PROPERTY_NOT_FOUND ) { continue ; } PropertyDescriptor prop = props [ columnToProperty [ i ] ] ; Class < ? > propType = prop . getPropertyType ( ) ; Object value = null ; if ( propType != null ) { value = this . processColumn ( rs , i , propType ) ; if ( value == null && propType . isPrimitive ( ) ) { value = primitiveDefaults . get ( propType ) ; } } this . callSetter ( bean , prop , value ) ; } return bean ; }
|
This method populates a bean from the ResultSet based upon the underlying meta - data .
|
731
|
private void callSetter ( Object target , PropertyDescriptor prop , Object value ) throws SQLException { Method setter = getWriteMethod ( target , prop , value ) ; if ( setter == null || setter . getParameterTypes ( ) . length != 1 ) { return ; } try { Class < ? > firstParam = setter . getParameterTypes ( ) [ 0 ] ; for ( PropertyHandler handler : propertyHandlers ) { if ( handler . match ( firstParam , value ) ) { value = handler . apply ( firstParam , value ) ; break ; } } if ( this . isCompatibleType ( value , firstParam ) ) { setter . invoke ( target , new Object [ ] { value } ) ; } else { throw new SQLException ( "Cannot set " + prop . getName ( ) + ": incompatible types, cannot convert " + value . getClass ( ) . getName ( ) + " to " + firstParam . getName ( ) ) ; } } catch ( IllegalArgumentException e ) { throw new SQLException ( "Cannot set " + prop . getName ( ) + ": " + e . getMessage ( ) ) ; } catch ( IllegalAccessException e ) { throw new SQLException ( "Cannot set " + prop . getName ( ) + ": " + e . getMessage ( ) ) ; } catch ( InvocationTargetException e ) { throw new SQLException ( "Cannot set " + prop . getName ( ) + ": " + e . getMessage ( ) ) ; } }
|
Calls the setter method on the target object for the given property . If no setter method exists for the property this method does nothing .
|
732
|
public void setString ( String string ) { this . string = string ; if ( string != null ) { this . length = string . length ( ) ; chars = this . string . toCharArray ( ) ; } else { this . length = 0 ; chars = new char [ 0 ] ; } reset ( ) ; }
|
Set the String we are currently parsing . The parser state is also reset to begin at the start of this string .
|
733
|
public String extract ( int start , int end ) { if ( ( start < 0 ) || ( start >= end ) || ( end > length ) ) return ( "" ) ; else return ( string . substring ( start , end ) ) ; }
|
Extract and return a substring that starts at the specified position and ends at the character before the specified position . If this is not possible a zero - length string is returned .
|
734
|
@ SuppressWarnings ( "unchecked" ) protected K createKey ( ResultSet rs ) throws SQLException { return ( columnName == null ) ? ( K ) rs . getObject ( columnIndex ) : ( K ) rs . getObject ( columnName ) ; }
|
so getObject will return the appropriate type and the cast will succeed .
|
735
|
private LinkedHashMapSegment < K , V > segmentFor ( int hash ) { int h = hash ( hash ) ; return segments [ ( h >>> segmentShift ) & segmentMask ] ; }
|
Returns the segment that should be used for key with given hash
|
736
|
public int size ( ) { try { lockAllSegments ( ) ; int size = 0 ; for ( LinkedHashMapSegment < K , V > seg : segments ) { size += seg . size ( ) ; } return size ; } finally { unlockAllSegments ( ) ; } }
|
Gets the entry s total number .
|
737
|
@ SuppressWarnings ( "unchecked" ) public V get ( Object key ) { LinkedHashMapSegment < K , V > seg = segmentFor ( key . hashCode ( ) ) ; try { seg . lock . lock ( ) ; return mapEventListener . onGetEntry ( ( K ) key , seg . get ( key ) ) ; } finally { seg . lock . unlock ( ) ; } }
|
Returns a value which the specified key is mapped . At the same time this method will call the callback interface the getting entry event will be triggered .
|
738
|
public V put ( K key , V value ) { LinkedHashMapSegment < K , V > seg = segmentFor ( key . hashCode ( ) ) ; try { seg . lock . lock ( ) ; return mapEventListener . onPutEntry ( key , value , seg . put ( key , value ) ) ; } finally { seg . lock . unlock ( ) ; } }
|
Associates the specified value with the specified key in this map . If the key existed in the map the entry will be replaced by specified entry . This method will call the putting entry event when the method is called .
|
739
|
@ SuppressWarnings ( "unchecked" ) public V remove ( Object key ) { LinkedHashMapSegment < K , V > seg = segmentFor ( key . hashCode ( ) ) ; try { seg . lock . lock ( ) ; return mapEventListener . onRemoveEntry ( ( K ) key , seg . remove ( key ) ) ; } finally { seg . lock . unlock ( ) ; } }
|
Remove a entry from this map . The removing event will be called .
|
740
|
public void clear ( ) { try { lockAllSegments ( ) ; for ( LinkedHashMapSegment < K , V > seg : segments ) { seg . clear ( ) ; } } finally { unlockAllSegments ( ) ; } }
|
clear all map s entries but it dosen t trigger the remove callback method
|
741
|
public Set < K > keySet ( ) { try { lockAllSegments ( ) ; Set < K > set = new HashSet < > ( ) ; for ( LinkedHashMapSegment < K , V > seg : segments ) { set . addAll ( seg . keySet ( ) ) ; } return set ; } finally { unlockAllSegments ( ) ; } }
|
Gets the all key in this map .
|
742
|
public static void copy ( File from , File to ) throws IOException { if ( from . isDirectory ( ) ) copyDir ( from , to ) ; else copyFile ( from , to ) ; }
|
Copy files or directories
|
743
|
public static < T > T [ ] addToArray ( T [ ] array , T item , Class < ? > type ) { if ( array == null ) { if ( type == null && item != null ) { type = item . getClass ( ) ; } @ SuppressWarnings ( "unchecked" ) T [ ] na = ( T [ ] ) Array . newInstance ( type , 1 ) ; na [ 0 ] = item ; return na ; } else { T [ ] na = Arrays . copyOf ( array , array . length + 1 ) ; na [ array . length ] = item ; return na ; } }
|
Add element to an array
|
744
|
public static < T > T [ ] prependToArray ( T item , T [ ] array , Class < ? > type ) { if ( array == null ) { if ( type == null && item != null ) { type = item . getClass ( ) ; } @ SuppressWarnings ( "unchecked" ) T [ ] na = ( T [ ] ) Array . newInstance ( type , 1 ) ; na [ 0 ] = item ; return na ; } else { Class < ? > c = array . getClass ( ) . getComponentType ( ) ; @ SuppressWarnings ( "unchecked" ) T [ ] na = ( T [ ] ) Array . newInstance ( c , Array . getLength ( array ) + 1 ) ; System . arraycopy ( array , 0 , na , 1 , array . length ) ; na [ 0 ] = item ; return na ; } }
|
Add element to the start of an array
|
745
|
public InputStream getInputStream ( ) throws IOException { if ( ! exists ( ) ) { throw new FileNotFoundException ( getPath ( ) + " (no such file or directory)" ) ; } if ( Files . isDirectory ( this . path ) ) { throw new FileNotFoundException ( getPath ( ) + " (is a directory)" ) ; } return Files . newInputStream ( this . path ) ; }
|
This implementation opens a InputStream for the underlying file .
|
746
|
public OutputStream getOutputStream ( ) throws IOException { if ( Files . isDirectory ( this . path ) ) { throw new FileNotFoundException ( getPath ( ) + " (is a directory)" ) ; } return Files . newOutputStream ( this . path ) ; }
|
This implementation opens a OutputStream for the underlying file .
|
747
|
public File getFile ( ) throws IOException { try { return this . path . toFile ( ) ; } catch ( UnsupportedOperationException ex ) { throw new FileNotFoundException ( this . path + " cannot be resolved to " + "absolute file path" ) ; } }
|
This implementation returns the underlying File reference .
|
748
|
public Resource createRelative ( String relativePath ) throws IOException { return new PathResource ( this . path . resolve ( relativePath ) ) ; }
|
This implementation creates a FileResource applying the given path relative to the path of the underlying file of this resource descriptor .
|
749
|
public E getUnsafe ( int index ) { int i = ( _nextE + index ) % _elements . length ; return at ( i ) ; }
|
Get without synchronization or bounds checking .
|
750
|
public static void quoteOnly ( Appendable buffer , String input ) { if ( input == null ) return ; try { buffer . append ( '"' ) ; for ( int i = 0 ; i < input . length ( ) ; ++ i ) { char c = input . charAt ( i ) ; if ( c == '"' || c == '\\' ) buffer . append ( '\\' ) ; buffer . append ( c ) ; } buffer . append ( '"' ) ; } catch ( IOException x ) { throw new RuntimeException ( x ) ; } }
|
Quote a string into an Appendable . Only quotes and backslash are escaped .
|
751
|
public static void quote ( Appendable buffer , String input ) { if ( input == null ) return ; try { buffer . append ( '"' ) ; for ( int i = 0 ; i < input . length ( ) ; ++ i ) { char c = input . charAt ( i ) ; if ( c >= 32 ) { if ( c == '"' || c == '\\' ) buffer . append ( '\\' ) ; buffer . append ( c ) ; } else { char escape = escapes [ c ] ; if ( escape == 0xFFFF ) { buffer . append ( '\\' ) . append ( 'u' ) . append ( '0' ) . append ( '0' ) ; if ( c < 0x10 ) buffer . append ( '0' ) ; buffer . append ( Integer . toString ( c , 16 ) ) ; } else { buffer . append ( '\\' ) . append ( escape ) ; } } } buffer . append ( '"' ) ; } catch ( IOException x ) { throw new RuntimeException ( x ) ; } }
|
Quote a string into an Appendable . The characters \ \ n \ r \ t \ f and \ b are escaped
|
752
|
public static String unquoteOnly ( String s , boolean lenient ) { if ( s == null ) return null ; if ( s . length ( ) < 2 ) return s ; char first = s . charAt ( 0 ) ; char last = s . charAt ( s . length ( ) - 1 ) ; if ( first != last || ( first != '"' && first != '\'' ) ) return s ; StringBuilder b = new StringBuilder ( s . length ( ) - 2 ) ; boolean escape = false ; for ( int i = 1 ; i < s . length ( ) - 1 ; i ++ ) { char c = s . charAt ( i ) ; if ( escape ) { escape = false ; if ( lenient && ! isValidEscaping ( c ) ) { b . append ( '\\' ) ; } b . append ( c ) ; } else if ( c == '\\' ) { escape = true ; } else { b . append ( c ) ; } } return b . toString ( ) ; }
|
Unquote a string NOT converting unicode sequences
|
753
|
public static boolean containsSqlScriptDelimiters ( String script , String delim ) { boolean inLiteral = false ; char [ ] content = script . toCharArray ( ) ; for ( int i = 0 ; i < script . length ( ) ; i ++ ) { if ( content [ i ] == '\'' ) { inLiteral = ! inLiteral ; } if ( ! inLiteral && script . startsWith ( delim , i ) ) { return true ; } } return false ; }
|
Does the provided SQL script contain the specified delimiter?
|
754
|
public static < A , O extends A > A [ ] addObjectToArray ( A [ ] array , O obj ) { Class < ? > compType = Object . class ; if ( array != null ) { compType = array . getClass ( ) . getComponentType ( ) ; } else if ( obj != null ) { compType = obj . getClass ( ) ; } int newArrLength = ( array != null ? array . length + 1 : 1 ) ; @ SuppressWarnings ( "unchecked" ) A [ ] newArr = ( A [ ] ) Array . newInstance ( compType , newArrLength ) ; if ( array != null ) { System . arraycopy ( array , 0 , newArr , 0 , array . length ) ; } newArr [ newArr . length - 1 ] = obj ; return newArr ; }
|
Append the given object to the given array returning a new array consisting of the input array contents plus the given object .
|
755
|
public static int [ ] compute ( int [ ] obs , int [ ] states , double [ ] startProb , double [ ] [ ] transProb , double [ ] [ ] emitProb ) { double [ ] [ ] v = new double [ obs . length ] [ states . length ] ; int [ ] [ ] path = new int [ states . length ] [ obs . length ] ; for ( int y : states ) { v [ 0 ] [ y ] = startProb [ y ] * emitProb [ y ] [ obs [ 0 ] ] ; path [ y ] [ 0 ] = y ; } for ( int t = 1 ; t < obs . length ; ++ t ) { int [ ] [ ] newPath = new int [ states . length ] [ obs . length ] ; for ( int y : states ) { double prob = - 1 ; int state ; for ( int y0 : states ) { double newProb = v [ t - 1 ] [ y0 ] * transProb [ y0 ] [ y ] * emitProb [ y ] [ obs [ t ] ] ; if ( newProb > prob ) { prob = newProb ; state = y0 ; v [ t ] [ y ] = prob ; System . arraycopy ( path [ state ] , 0 , newPath [ y ] , 0 , t ) ; newPath [ y ] [ t ] = y ; } } } path = newPath ; } double prob = - 1 ; int state = 0 ; for ( int y : states ) { if ( v [ obs . length - 1 ] [ y ] > prob ) { prob = v [ obs . length - 1 ] [ y ] ; state = y ; } } return path [ state ] ; }
|
Compute HMM hidden states
|
756
|
public void clear ( ) { Optional . ofNullable ( phantomReference ) . ifPresent ( ref -> pool . getLeakDetector ( ) . clear ( ref ) ) ; }
|
Clear leak track
|
757
|
public static int stringSize ( long x ) { long p = 10 ; for ( int i = 1 ; i < 19 ; i ++ ) { if ( x < p ) return i ; p = 10 * p ; } return 19 ; }
|
Requires positive x
|
758
|
public static < V > Action1 < TaskContext < V > > fixedWait ( long sleepTime , TimeUnit timeUnit ) { return ctx -> ThreadUtils . sleep ( sleepTime , timeUnit ) ; }
|
The fixed sleep time .
|
759
|
public static String buildErrorMessage ( String stmt , int stmtNumber , EncodedResource encodedResource ) { return String . format ( "Failed to execute SQL script statement #%s of %s: %s" , stmtNumber , encodedResource , stmt ) ; }
|
Build an error message for an SQL script execution failure based on the supplied arguments .
|
760
|
public static < V > Predicate < TaskContext < V > > afterDelay ( long time , TimeUnit timeUnit ) { return ctx -> ( System . currentTimeMillis ( ) - ctx . getStartTime ( ) ) >= timeUnit . toMillis ( time ) ; }
|
If the task executed time exceeds the specified time the task will stop retry .
|
761
|
public static < V > Predicate < TaskContext < V > > afterExecute ( int count ) { return ctx -> ctx . getExecutedCount ( ) >= count ; }
|
If the task executed count exceeds the max count the task will stop retry .
|
762
|
public static ByteBuffer allocate ( int capacity ) { ByteBuffer buf = ByteBuffer . allocate ( capacity ) ; buf . limit ( 0 ) ; return buf ; }
|
Allocate ByteBuffer in flush mode . The position and limit will both be zero indicating that the buffer is empty and must be flipped before any data is put to it .
|
763
|
public static ByteBuffer allocateDirect ( int capacity ) { ByteBuffer buf = ByteBuffer . allocateDirect ( capacity ) ; buf . limit ( 0 ) ; return buf ; }
|
Allocate ByteBuffer in flush mode . The position and limit will both be zero indicating that the buffer is empty and in flush mode .
|
764
|
public static void clearToFill ( ByteBuffer buffer ) { if ( buffer != null ) { buffer . position ( 0 ) ; buffer . limit ( buffer . capacity ( ) ) ; } }
|
Clear the buffer to be empty in fill mode . The position is set to 0 and the limit is set to the capacity .
|
765
|
public static byte [ ] toArray ( ByteBuffer buffer ) { if ( buffer . hasArray ( ) ) { byte [ ] array = buffer . array ( ) ; int from = buffer . arrayOffset ( ) + buffer . position ( ) ; return Arrays . copyOfRange ( array , from , from + buffer . remaining ( ) ) ; } else { byte [ ] to = new byte [ buffer . remaining ( ) ] ; buffer . slice ( ) . get ( to ) ; return to ; } }
|
Convert a ByteBuffer to a byte array .
|
766
|
public static boolean compact ( ByteBuffer buffer ) { if ( buffer . position ( ) == 0 ) return false ; boolean full = buffer . limit ( ) == buffer . capacity ( ) ; buffer . compact ( ) . flip ( ) ; return full && buffer . limit ( ) < buffer . capacity ( ) ; }
|
Compact the buffer
|
767
|
public static void append ( ByteBuffer to , byte [ ] b , int off , int len ) throws BufferOverflowException { int pos = flipToFill ( to ) ; try { to . put ( b , off , len ) ; } finally { flipToFlush ( to , pos ) ; } }
|
Append bytes to a buffer .
|
768
|
public static void append ( ByteBuffer to , byte b ) { int pos = flipToFill ( to ) ; try { to . put ( b ) ; } finally { flipToFlush ( to , pos ) ; } }
|
Appends a byte to a buffer
|
769
|
public static ByteBuffer toBuffer ( byte [ ] array ) { if ( array == null ) return EMPTY_BUFFER ; return toBuffer ( array , 0 , array . length ) ; }
|
Create a new ByteBuffer using provided byte array .
|
770
|
public static ByteBuffer toBuffer ( byte array [ ] , int offset , int length ) { if ( array == null ) return EMPTY_BUFFER ; return ByteBuffer . wrap ( array , offset , length ) ; }
|
Create a new ByteBuffer using the provided byte array .
|
771
|
public static String toDetailString ( ByteBuffer buffer ) { if ( buffer == null ) return "null" ; StringBuilder buf = new StringBuilder ( ) ; idString ( buffer , buf ) ; buf . append ( "[p=" ) ; buf . append ( buffer . position ( ) ) ; buf . append ( ",l=" ) ; buf . append ( buffer . limit ( ) ) ; buf . append ( ",c=" ) ; buf . append ( buffer . capacity ( ) ) ; buf . append ( ",r=" ) ; buf . append ( buffer . remaining ( ) ) ; buf . append ( "]={" ) ; appendDebugString ( buf , buffer ) ; buf . append ( "}" ) ; return buf . toString ( ) ; }
|
Convert Buffer to a detail debug string of pointers and content
|
772
|
public static String toHexSummary ( ByteBuffer buffer ) { if ( buffer == null ) return "null" ; StringBuilder buf = new StringBuilder ( ) ; buf . append ( "b[" ) . append ( buffer . remaining ( ) ) . append ( "]=" ) ; for ( int i = buffer . position ( ) ; i < buffer . limit ( ) ; i ++ ) { TypeUtils . toHex ( buffer . get ( i ) , buf ) ; if ( i == buffer . position ( ) + 24 && buffer . limit ( ) > buffer . position ( ) + 32 ) { buf . append ( "..." ) ; i = buffer . limit ( ) - 8 ; } } return buf . toString ( ) ; }
|
Convert buffer to a Hex Summary String .
|
773
|
public static String toHexString ( ByteBuffer buffer ) { if ( buffer == null ) return "null" ; return TypeUtils . toHexString ( toArray ( buffer ) ) ; }
|
Convert buffer to a Hex String .
|
774
|
public static Object addArray ( Object list , Object [ ] array ) { for ( int i = 0 ; array != null && i < array . length ; i ++ ) list = LazyList . add ( list , array [ i ] ) ; return list ; }
|
Add the contents of an array to a LazyList
|
775
|
public static Object ensureSize ( Object list , int initialSize ) { if ( list == null ) return new ArrayList < Object > ( initialSize ) ; if ( list instanceof ArrayList ) { ArrayList < ? > ol = ( ArrayList < ? > ) list ; if ( ol . size ( ) > initialSize ) return ol ; ArrayList < Object > nl = new ArrayList < Object > ( initialSize ) ; nl . addAll ( ol ) ; return nl ; } List < Object > l = new ArrayList < Object > ( initialSize ) ; l . add ( list ) ; return l ; }
|
Ensure the capacity of the underlying list .
|
776
|
public static boolean hasEntry ( Object list ) { if ( list == null ) return false ; if ( list instanceof List ) return ! ( ( List < ? > ) list ) . isEmpty ( ) ; return true ; }
|
Simple utility method to test if List has at least 1 entry .
|
777
|
public static Object toArray ( Object list , Class < ? > clazz ) { if ( list == null ) return Array . newInstance ( clazz , 0 ) ; if ( list instanceof List ) { List < ? > l = ( List < ? > ) list ; if ( clazz . isPrimitive ( ) ) { Object a = Array . newInstance ( clazz , l . size ( ) ) ; for ( int i = 0 ; i < l . size ( ) ; i ++ ) Array . set ( a , i , l . get ( i ) ) ; return a ; } return l . toArray ( ( Object [ ] ) Array . newInstance ( clazz , l . size ( ) ) ) ; } Object a = Array . newInstance ( clazz , 1 ) ; Array . set ( a , 0 , list ) ; return a ; }
|
Convert a lazylist to an array
|
778
|
public static int size ( Object list ) { if ( list == null ) return 0 ; if ( list instanceof List ) return ( ( List < ? > ) list ) . size ( ) ; return 1 ; }
|
The size of a lazy List
|
779
|
public void close ( ) throws IOException { try { if ( inPart ) out . write ( __CRLF ) ; out . write ( __DASHDASH ) ; out . write ( boundary ) ; out . write ( __DASHDASH ) ; out . write ( __CRLF ) ; inPart = false ; } finally { super . close ( ) ; } }
|
End the current part .
|
780
|
public void register ( Task task ) { Optional . ofNullable ( task ) . filter ( t -> t . getTask ( ) != null ) . filter ( t -> StringUtils . hasText ( t . getName ( ) ) ) . ifPresent ( t -> checkTaskMap . put ( t . getName ( ) , t ) ) ; }
|
Register a health check task .
|
781
|
public void checkSize ( int length , boolean huffman ) throws HpackException . SessionException { if ( huffman ) length = ( length * 4 ) / 3 ; if ( ( _size + length ) > _maxSize ) throw new HpackException . SessionException ( "Header too large %d > %d" , _size + length , _maxSize ) ; }
|
Check that the max size will not be exceeded .
|
782
|
public Future add ( long delay , Runnable run ) { final int curSlot = currentSlot ; final int ticks = delay > interval ? ( int ) ( delay / interval ) : 1 ; final int index = ( curSlot + ( ticks % maxTimers ) ) % maxTimers ; final int round = ( ticks - 1 ) / maxTimers ; TimerTask task = new TimerTask ( round , run ) ; timerSlots [ index ] . add ( task ) ; return new Future ( this , index , task ) ; }
|
add a task
|
783
|
public boolean add ( T elem ) { if ( size ( ) == mArrays . length * mArrays . length ) grow ( ) ; final int offset = computeOffset ( size ( ) ) ; final int index = computeIndex ( size ( ) ) ; if ( mArrays [ offset ] == null ) mArrays [ offset ] = ( T [ ] ) new Object [ mArrays . length ] ; mArrays [ offset ] [ index ] = elem ; ++ mSize ; return true ; }
|
Adds a new element to the HashedArrayTree .
|
784
|
public T set ( int index , T elem ) { final int offset = computeOffset ( index ) ; final int arrIndex = computeIndex ( index ) ; T result = mArrays [ offset ] [ arrIndex ] ; mArrays [ offset ] [ arrIndex ] = elem ; return result ; }
|
Sets the element at the specified position to the indicated value . If the index is out of bounds throws an IndexOutOfBounds exception .
|
785
|
public T get ( int index ) { if ( index < 0 || index >= size ( ) ) throw new IndexOutOfBoundsException ( "Index " + index + ", size " + size ( ) ) ; return mArrays [ computeOffset ( index ) ] [ computeIndex ( index ) ] ; }
|
Returns the value of the element at the specified position .
|
786
|
public void add ( int index , T elem ) { if ( index < 0 || index >= size ( ) ) throw new IndexOutOfBoundsException ( "Index " + index + ", size " + size ( ) ) ; add ( null ) ; for ( int i = size ( ) ; i > index ; ++ i ) set ( i , get ( i - 1 ) ) ; set ( index , elem ) ; }
|
Adds the specified element at the position just before the specified index .
|
787
|
public T remove ( int index ) { T result = get ( index ) ; for ( int i = index + 1 ; i < size ( ) ; ++ i ) set ( i - 1 , get ( i ) ) ; set ( size ( ) - 1 , null ) ; -- mSize ; if ( size ( ) * 8 <= mArrays . length * mArrays . length ) shrink ( ) ; else if ( size ( ) % mArrays . length == 0 ) mArrays [ computeOffset ( size ( ) ) ] = null ; return result ; }
|
Removes the element at the specified position from the HashedArrayTree .
|
788
|
private void grow ( ) { T [ ] [ ] newArrays = ( T [ ] [ ] ) new Object [ mArrays . length * 2 ] [ ] ; for ( int i = 0 ; i < mArrays . length ; i += 2 ) { newArrays [ i / 2 ] = ( T [ ] ) new Object [ newArrays . length ] ; System . arraycopy ( mArrays [ i ] , 0 , newArrays [ i / 2 ] , 0 , mArrays . length ) ; System . arraycopy ( mArrays [ i + 1 ] , 0 , newArrays [ i / 2 ] , mArrays . length , mArrays . length ) ; mArrays [ i ] = mArrays [ i + 1 ] = null ; } mArrays = newArrays ; ++ mLgSize ; }
|
Grows the internal representation by doubling the size of the topmost array and copying the appropriate number of elements over .
|
789
|
private void shrink ( ) { if ( mArrays . length == kMinArraySize ) return ; T [ ] [ ] newArrays = ( T [ ] [ ] ) new Object [ mArrays . length / 2 ] [ ] ; for ( int i = 0 ; i < newArrays . length / 2 ; ++ i ) { newArrays [ i ] = ( T [ ] ) new Object [ newArrays . length ] ; System . arraycopy ( mArrays [ i / 2 ] , ( i % 2 == 0 ) ? 0 : newArrays . length , newArrays [ i ] , 0 , newArrays . length ) ; if ( i % 2 == 1 ) mArrays [ i / 2 ] = null ; } mArrays = newArrays ; -- mLgSize ; }
|
Decreases the size of the HAT by shrinking into a better fit .
|
790
|
public void lock ( ) { Thread t = Thread . currentThread ( ) ; if ( t == owner . get ( ) ) { count ++ ; return ; } while ( owner . compareAndSet ( null , t ) ) { } }
|
reentrant count of a thread no need to be volatile
|
791
|
public Map < String , String > getCopyOfContextMap ( ) { Map < String , String > oldMap = inheritableThreadLocal . get ( ) ; if ( oldMap != null ) { return new HashMap < > ( oldMap ) ; } else { return null ; } }
|
Return a copy of the current thread s context map . Returned value may be null .
|
792
|
public int getAndSetHi ( int hi ) { while ( true ) { long encoded = get ( ) ; long update = encodeHi ( encoded , hi ) ; if ( compareAndSet ( encoded , update ) ) return getHi ( encoded ) ; } }
|
Atomically sets the hi value without changing the lo value .
|
793
|
public int getAndSetLo ( int lo ) { while ( true ) { long encoded = get ( ) ; long update = encodeLo ( encoded , lo ) ; if ( compareAndSet ( encoded , update ) ) return getLo ( encoded ) ; } }
|
Atomically sets the lo value without changing the hi value .
|
794
|
public int addAndGetHi ( int delta ) { while ( true ) { long encoded = get ( ) ; int hi = getHi ( encoded ) + delta ; long update = encodeHi ( encoded , hi ) ; if ( compareAndSet ( encoded , update ) ) return hi ; } }
|
Atomically adds the given delta to the current hi value returning the updated hi value .
|
795
|
public int addAndGetLo ( int delta ) { while ( true ) { long encoded = get ( ) ; int lo = getLo ( encoded ) + delta ; long update = encodeLo ( encoded , lo ) ; if ( compareAndSet ( encoded , update ) ) return lo ; } }
|
Atomically adds the given delta to the current lo value returning the updated lo value .
|
796
|
public void add ( int deltaHi , int deltaLo ) { while ( true ) { long encoded = get ( ) ; long update = encode ( getHi ( encoded ) + deltaHi , getLo ( encoded ) + deltaLo ) ; if ( compareAndSet ( encoded , update ) ) return ; } }
|
Atomically adds the given deltas to the current hi and lo values .
|
797
|
public static long encode ( int hi , int lo ) { long h = ( ( long ) hi ) & 0xFFFF_FFFFL ; long l = ( ( long ) lo ) & 0xFFFF_FFFFL ; return ( h << 32 ) + l ; }
|
Encodes hi and lo values into a long .
|
798
|
public static long encodeHi ( long encoded , int hi ) { long h = ( ( long ) hi ) & 0xFFFF_FFFFL ; long l = encoded & 0xFFFF_FFFFL ; return ( h << 32 ) + l ; }
|
Sets the hi value into the given encoded value .
|
799
|
public static long encodeLo ( long encoded , int lo ) { long h = ( encoded >> 32 ) & 0xFFFF_FFFFL ; long l = ( ( long ) lo ) & 0xFFFF_FFFFL ; return ( h << 32 ) + l ; }
|
Sets the lo value into the given encoded value .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.