signature:
public class DragAndDropHandler { /** * Retrieves the { @ code View } in the list corresponding to itemId .
 * @ return the { @ code View } , or { @ code null } if not found . */
@ Nullable private View getViewForId ( final long itemId ) { } }

implementation: ListAdapter adapter = mAdapter ; if ( itemId == INVALID_ID || adapter == null ) { return null ; } int firstVisiblePosition = mWrapper . getFirstVisiblePosition ( ) ; View result = null ; for ( int i = 0 ; i < mWrapper . getChildCount ( ) && result == null ; i ++ ) { int position = firstVisiblePosition + i ; if ( position - mWrapper . getHeaderViewsCount ( ) >= 0 ) { long id = adapter . getItemId ( position - mWrapper . getHeaderViewsCount ( ) ) ; if ( id == itemId ) { result = mWrapper . getChildAt ( i ) ; } } } return result ;


signature:
public class DragAndDropHandler { /** * Handles the move events .
 * Applies the { @ link MotionEvent } to the hover drawable , and switches { @ code View } s if necessary .
 * @ param event the { @ code MotionEvent } .
 * @ return { @ code true } if the event was handled , { @ code false } otherwise . */
private boolean handleMoveEvent ( @ NonNull final MotionEvent event ) { } }

implementation: boolean handled = false ; float deltaX = event . getRawX ( ) - mDownX ; float deltaY = event . getRawY ( ) - mDownY ; if ( mHoverDrawable == null && Math . abs ( deltaY ) > mSlop && Math . abs ( deltaY ) > Math . abs ( deltaX ) ) { int position = mWrapper . pointToPosition ( ( int ) event . getX ( ) , ( int ) event . getY ( ) ) ; if ( position != AdapterView . INVALID_POSITION ) { View downView = mWrapper . getChildAt ( position - mWrapper . getFirstVisiblePosition ( ) ) ; assert downView != null ; if ( mDraggableManager . isDraggable ( downView , position - mWrapper . getHeaderViewsCount ( ) , event . getX ( ) - downView . getX ( ) , event . getY ( ) - downView . getY ( ) ) ) { startDragging ( position - mWrapper . getHeaderViewsCount ( ) ) ; handled = true ; } } } else if ( mHoverDrawable != null ) { mHoverDrawable . handleMoveEvent ( event ) ; switchIfNecessary ( ) ; mWrapper . getListView ( ) . invalidate ( ) ; handled = true ; } return handled ;


signature:
public class DragAndDropHandler { /** * Finds the { @ code View } that is a candidate for switching , and executes the switch if necessary . */
private void switchIfNecessary ( ) { } }

implementation: if ( mHoverDrawable == null || mAdapter == null ) { return ; } int position = getPositionForId ( mMobileItemId ) ; long aboveItemId = position - 1 - mWrapper . getHeaderViewsCount ( ) >= 0 ? mAdapter . getItemId ( position - 1 - mWrapper . getHeaderViewsCount ( ) ) : INVALID_ID ; long belowItemId = position + 1 - mWrapper . getHeaderViewsCount ( ) < mAdapter . getCount ( ) ? mAdapter . getItemId ( position + 1 - mWrapper . getHeaderViewsCount ( ) ) : INVALID_ID ; final long switchId = mHoverDrawable . isMovingUpwards ( ) ? aboveItemId : belowItemId ; View switchView = getViewForId ( switchId ) ; final int deltaY = mHoverDrawable . getDeltaY ( ) ; if ( switchView != null && Math . abs ( deltaY ) > mHoverDrawable . getIntrinsicHeight ( ) ) { switchViews ( switchView , switchId , mHoverDrawable . getIntrinsicHeight ( ) * ( deltaY < 0 ? - 1 : 1 ) ) ; } mScrollHandler . handleMobileCellScroll ( ) ; mWrapper . getListView ( ) . invalidate ( ) ;


signature:
public class DragAndDropHandler { /** * Switches the item that is currently being dragged with the item belonging to given id ,
 * by notifying the adapter to swap positions and that the data set has changed .
 * @ param switchView the { @ code View } that should be animated towards the old position of the currently dragging item .
 * @ param switchId the id of the item that will take the position of the currently dragging item .
 * @ param translationY the distance in pixels the { @ code switchView } should animate - i . e . the ( positive or negative ) height of the { @ code View } corresponding to the currently
 * dragging item . */
private void switchViews ( final View switchView , final long switchId , final float translationY ) { } }

implementation: assert mHoverDrawable != null ; assert mAdapter != null ; assert mMobileView != null ; final int switchViewPosition = mWrapper . getPositionForView ( switchView ) ; int mobileViewPosition = mWrapper . getPositionForView ( mMobileView ) ; ( ( Swappable ) mAdapter ) . swapItems ( switchViewPosition - mWrapper . getHeaderViewsCount ( ) , mobileViewPosition - mWrapper . getHeaderViewsCount ( ) ) ; ( ( BaseAdapter ) mAdapter ) . notifyDataSetChanged ( ) ; mHoverDrawable . shift ( switchView . getHeight ( ) ) ; mSwitchViewAnimator . animateSwitchView ( switchId , translationY ) ;


signature:
public class DragAndDropHandler { /** * Handles the up event .
 * Animates the hover drawable to its final position , and finalizes our drag properties when the animation has finished .
 * Will also notify the { @ link com . nhaarman . listviewanimations . itemmanipulation . dragdrop . OnItemMovedListener } set if applicable .
 * @ return { @ code true } if the event was handled , { @ code false } otherwise . */
private boolean handleUpEvent ( ) { } }

implementation: if ( mMobileView == null ) { return false ; } assert mHoverDrawable != null ; ValueAnimator valueAnimator = ValueAnimator . ofInt ( mHoverDrawable . getTop ( ) , ( int ) mMobileView . getY ( ) ) ; SettleHoverDrawableAnimatorListener listener = new SettleHoverDrawableAnimatorListener ( mHoverDrawable , mMobileView ) ; valueAnimator . addUpdateListener ( listener ) ; valueAnimator . addListener ( listener ) ; valueAnimator . start ( ) ; int newPosition = getPositionForId ( mMobileItemId ) - mWrapper . getHeaderViewsCount ( ) ; if ( mOriginalMobileItemPosition != newPosition && mOnItemMovedListener != null ) { mOnItemMovedListener . onItemMoved ( mOriginalMobileItemPosition , newPosition ) ; } return true ;


signature:
public class InsertQueue { /** * Insert an item into the queue at given index . Will directly call { @ link Insertable # add ( int ,
 * Object ) } if there are no active index - item pairs . Otherwise , the pair will be queued .
 * @ param index the index at which the item should be inserted .
 * @ param item the item to insert . */
public void insert ( final int index , @ NonNull final T item ) { } }

implementation:
if ( mActiveIndexes . isEmpty ( ) && mPendingItemsToInsert . isEmpty ( ) ) { mActiveIndexes . add ( new AtomicInteger ( index ) ) ; // noinspection unchecked
mInsertable . add ( index , item ) ; } else { mPendingItemsToInsert . add ( new Pair < > ( index , item ) ) ; }


signature:
public class InsertQueue { /** * Clear the active state for given index . Will insert any pending pairs if this call leads to a state where there are no active pairs .
 * @ param index the index to remove . */
public void removeActiveIndex ( final int index ) { } }

implementation: boolean found = false ; for ( Iterator < AtomicInteger > iterator = mActiveIndexes . iterator ( ) ; iterator . hasNext ( ) && ! found ; ) { if ( iterator . next ( ) . get ( ) == index ) { iterator . remove ( ) ; found = true ; } } if ( mActiveIndexes . isEmpty ( ) ) { insertPending ( ) ; }


signature:
public class InsertQueue { /** * Inserts pending items into the Insertable , and adds them to the active positions ( correctly managing position shifting ) . Clears the pending items . */
private void insertPending ( ) { } }

implementation: for ( Pair < Integer , T > pi : mPendingItemsToInsert ) { for ( AtomicInteger existing : mActiveIndexes ) { if ( existing . intValue ( ) >= pi . first ) { existing . incrementAndGet ( ) ; } } mActiveIndexes . add ( new AtomicInteger ( pi . first ) ) ; mInsertable . add ( pi . first , pi . second ) ; } mPendingItemsToInsert . clear ( ) ;


signature:
public class InsertQueue { /** * Returns a collection of currently active indexes . */
@ NonNull public Collection < Integer > getActiveIndexes ( ) { } }

implementation: Collection < Integer > result = new HashSet < > ( ) ; for ( AtomicInteger i : mActiveIndexes ) { result . add ( i . get ( ) ) ; } return result ;


signature:
public class ExpandableListItemAdapter { /** * Return the title view at the specified position .
 * @ param position Index of the view we want .
 * @ return the view if it exist , null otherwise . */
@ Nullable public View getTitleView ( final int position ) { } }

implementation: View titleView = null ; View parentView = findViewForPosition ( position ) ; if ( parentView != null ) { Object tag = parentView . getTag ( ) ; if ( tag instanceof ViewHolder ) { titleView = ( ( ViewHolder ) tag ) . titleView ; } } return titleView ;


signature:
public class ExpandableListItemAdapter { /** * Return the content view at the specified position .
 * @ param position Index of the view we want .
 * @ return the view if it exist , null otherwise . */
@ Nullable public View getContentView ( final int position ) { } }

implementation: View contentView = null ; View parentView = findViewForPosition ( position ) ; if ( parentView != null ) { Object tag = parentView . getTag ( ) ; if ( tag instanceof ViewHolder ) { contentView = ( ( ViewHolder ) tag ) . contentView ; } } return contentView ;


signature:
public class ExpandableListItemAdapter { /** * Expand the view at given position . Will do nothing if the view is already expanded .
 * @ param position the position to expand . */
public void expand ( final int position ) { } }

implementation: long itemId = getItemId ( position ) ; if ( mExpandedIds . contains ( itemId ) ) { return ; } toggle ( position ) ;


signature:
public class ExpandableListItemAdapter { /** * Collapse the view at given position . Will do nothing if the view is already collapsed .
 * @ param position the position to collapse . */
public void collapse ( final int position ) { } }

implementation: long itemId = getItemId ( position ) ; if ( ! mExpandedIds . contains ( itemId ) ) { return ; } toggle ( position ) ;


signature:
public class ExpandableListItemAdapter { /** * Toggle the { @ link android . view . View } at given position , ignores header or footer Views .
 * @ param position the position of the view to toggle . */
public void toggle ( final int position ) { } }

implementation: long itemId = getItemId ( position ) ; boolean isExpanded = mExpandedIds . contains ( itemId ) ; View contentParent = getContentParent ( position ) ; if ( contentParent != null ) { toggle ( contentParent ) ; } if ( contentParent == null && isExpanded ) { mExpandedIds . remove ( itemId ) ; } else if ( contentParent == null ) { mExpandedIds . add ( itemId ) ; }


signature:
public class ExpandableListItemAdapter { /** * Return the content parent at the specified position .
 * @ param position Index of the view we want .
 * @ return the view if it exist , null otherwise . */
@ Nullable private View getContentParent ( final int position ) { } }

implementation: View contentParent = null ; View parentView = findViewForPosition ( position ) ; if ( parentView != null ) { Object tag = parentView . getTag ( ) ; if ( tag instanceof ViewHolder ) { contentParent = ( ( ViewHolder ) tag ) . contentParent ; } } return contentParent ;


signature:
public class AnimateAdditionAdapter { /** * Inserts items , starting at given index . Will show an entrance animation for the new items if the newly added items are visible .
 * Will also call { @ link Insertable # add ( int , Object ) } of the root { @ link android . widget . BaseAdapter } .
 * @ param index the starting index the new items should be inserted at .
 * @ param items the items to insert . */
public void insert ( final int index , @ NonNull final T ... items ) { } }

implementation: Pair < Integer , T > [ ] pairs = new Pair [ items . length ] ; for ( int i = 0 ; i < items . length ; i ++ ) { pairs [ i ] = new Pair < > ( index + i , items [ i ] ) ; } insert ( pairs ) ;


signature:
public class AnimateAdditionAdapter { /** * Inserts items at given indexes . Will show an entrance animation for the new items if the newly added item is visible .
 * Will also call { @ link Insertable # add ( int , Object ) } of the root { @ link android . widget . BaseAdapter } .
 * @ param indexItemPairs the index - item pairs to insert . The first argument of the { @ code Pair } is the index , the second argument is the item . */
public void insert ( @ NonNull final Pair < Integer , T > ... indexItemPairs ) { } }

implementation: insert ( Arrays . asList ( indexItemPairs ) ) ;


signature:
public class AnimateAdditionAdapter { /** * Inserts items at given indexes . Will show an entrance animation for the new items if the newly added item is visible .
 * Will also call { @ link Insertable # add ( int , Object ) } of the root { @ link android . widget . BaseAdapter } .
 * @ param indexItemPairs the index - item pairs to insert . The first argument of the { @ code Pair } is the index , the second argument is the item . */
public void insert ( @ NonNull final Iterable < Pair < Integer , T > > indexItemPairs ) { } }

implementation:
if ( getListViewWrapper ( ) == null ) { throw new IllegalStateException ( "Call setListView on this AnimateAdditionAdapter!" ) ; } Collection < Pair < Integer , T > > visibleViews = new ArrayList < > ( ) ; Collection < Integer > insertedPositions = new ArrayList < > ( ) ; Collection < Integer > insertedBelowPositions = new ArrayList < > ( ) ; int scrollDistance = 0 ; int numInsertedAbove = 0 ; for ( Pair < Integer , T > pair : indexItemPairs ) { if ( getListViewWrapper ( ) . getFirstVisiblePosition ( ) > pair . first ) { /* Inserting an item above the first visible position */
int index = pair . first ; /* Correct the index for already inserted positions above the first visible view . */
for ( int insertedPosition : insertedPositions ) { if ( index >= insertedPosition ) { index ++ ; } } mInsertable . add ( index , pair . second ) ; insertedPositions . add ( index ) ; numInsertedAbove ++ ; if ( mShouldAnimateDown ) { View view = getView ( pair . first , null , getListViewWrapper ( ) . getListView ( ) ) ; view . measure ( View . MeasureSpec . makeMeasureSpec ( 0 , View . MeasureSpec . UNSPECIFIED ) , View . MeasureSpec . makeMeasureSpec ( 0 , View . MeasureSpec . UNSPECIFIED ) ) ; scrollDistance -= view . getMeasuredHeight ( ) ; } } else if ( getListViewWrapper ( ) . getLastVisiblePosition ( ) >= pair . first || getListViewWrapper ( ) . getLastVisiblePosition ( ) == AdapterView . INVALID_POSITION || ! childrenFillAbsListView ( ) ) { /* Inserting an item that becomes visible on screen */
int index = pair . first ; /* Correct the index for already inserted positions above the first visible view */
for ( int insertedPosition : insertedPositions ) { if ( index >= insertedPosition ) { index ++ ; } } Pair < Integer , T > newPair = new Pair < > ( index , pair . second ) ; visibleViews . add ( newPair ) ; } else { /* Inserting an item below the last visible item */
int index = pair . first ; /* Correct the index for already inserted positions above the first visible view */
for ( int insertedPosition : insertedPositions ) { if ( index >= insertedPosition ) { index ++ ; } } /* Correct the index for already inserted positions below the last visible view */
for ( int queuedPosition : insertedBelowPositions ) { if ( index >= queuedPosition ) { index ++ ; } } insertedBelowPositions . add ( index ) ; mInsertable . add ( index , pair . second ) ; } } if ( mShouldAnimateDown ) { ( ( AbsListView ) getListViewWrapper ( ) . getListView ( ) ) . smoothScrollBy ( scrollDistance , ( int ) ( mScrolldownAnimationDurationMs * numInsertedAbove ) ) ; } mInsertQueue . insert ( visibleViews ) ; int firstVisiblePosition = getListViewWrapper ( ) . getFirstVisiblePosition ( ) ; View firstChild = getListViewWrapper ( ) . getChildAt ( 0 ) ; int childTop = firstChild == null ? 0 : firstChild . getTop ( ) ; ( ( ListView ) getListViewWrapper ( ) . getListView ( ) ) . setSelectionFromTop ( firstVisiblePosition + numInsertedAbove , childTop ) ;


signature:
public class AnimateAdditionAdapter { /** * Override this method to provide additional animators on top of the default height and alpha animation .
 * @ param view The { @ link android . view . View } that will get animated .
 * @ param parent The parent that this view will eventually be attached to .
 * @ return a non - null array of Animators . */
@ SuppressWarnings ( { } }

implementation: "MethodMayBeStatic" , "UnusedParameters" } ) @ NonNull protected Animator [ ] getAdditionalAnimators ( @ NonNull final View view , @ NonNull final ViewGroup parent ) { return new Animator [ ] { } ;


signature:
public class DynamicListView { /** * Enables the drag and drop functionality for this { @ code DynamicListView } .
 * < b > NOTE : This method can only be called on devices running ICS ( 14 ) and above , otherwise an exception will be thrown . < / b >
 * @ throws java . lang . UnsupportedOperationException if the device uses an older API than 14. */
public void enableDragAndDrop ( ) { } }

implementation: if ( Build . VERSION . SDK_INT < Build . VERSION_CODES . ICE_CREAM_SANDWICH ) { throw new UnsupportedOperationException ( "Drag and drop is only supported API levels 14 and up!" ) ; } mDragAndDropHandler = new DragAndDropHandler ( this ) ;


signature:
public class DynamicListView { /** * Enables swipe to dismiss with contextual undo for this { @ code DynamicListView } .
 * This method requires that a { @ link com . nhaarman . listviewanimations . itemmanipulation . swipedismiss . undo . SwipeUndoAdapter } has been set .
 * It is allowed to have the { @ code SwipeUndoAdapter } wrapped in a { @ link com . nhaarman . listviewanimations . BaseAdapterDecorator } .
 * @ throws java . lang . IllegalStateException if the adapter that was set does not extend { @ code SwipeUndoAdapter } . */
public void enableSimpleSwipeUndo ( ) { } }

implementation: if ( mSwipeUndoAdapter == null ) { throw new IllegalStateException ( "enableSimpleSwipeUndo requires a SwipeUndoAdapter to be set as an adapter" ) ; } mSwipeTouchListener = new SwipeUndoTouchListener ( new DynamicListViewWrapper ( this ) , mSwipeUndoAdapter . getUndoCallback ( ) ) ; mSwipeUndoAdapter . setSwipeUndoTouchListener ( ( SwipeUndoTouchListener ) mSwipeTouchListener ) ;


signature:
public class DynamicListView { /** * Sets the { @ link ListAdapter } for this { @ code DynamicListView } .
 * If the drag and drop functionality is or will be enabled , the adapter should have stable ids ,
 * and should implement { @ link com . nhaarman . listviewanimations . util . Swappable } .
 * @ param adapter the adapter .
 * @ throws java . lang . IllegalStateException if the drag and drop functionality is enabled
 * and the adapter does not have stable ids .
 * @ throws java . lang . IllegalArgumentException if the drag and drop functionality is enabled
 * and the adapter does not implement { @ link com . nhaarman . listviewanimations . util . Swappable } . */
@ Override public void setAdapter ( final ListAdapter adapter ) { } }

implementation: ListAdapter wrappedAdapter = adapter ; mSwipeUndoAdapter = null ; if ( adapter instanceof BaseAdapter ) { BaseAdapter rootAdapter = ( BaseAdapter ) wrappedAdapter ; while ( rootAdapter instanceof BaseAdapterDecorator ) { if ( rootAdapter instanceof SwipeUndoAdapter ) { mSwipeUndoAdapter = ( SwipeUndoAdapter ) rootAdapter ; } rootAdapter = ( ( BaseAdapterDecorator ) rootAdapter ) . getDecoratedBaseAdapter ( ) ; } if ( rootAdapter instanceof Insertable ) { mAnimateAdditionAdapter = new AnimateAdditionAdapter ( ( BaseAdapter ) wrappedAdapter ) ; mAnimateAdditionAdapter . setListView ( this ) ; wrappedAdapter = mAnimateAdditionAdapter ; } } super . setAdapter ( wrappedAdapter ) ; if ( mDragAndDropHandler != null ) { mDragAndDropHandler . setAdapter ( adapter ) ; }


signature:
public class DynamicListView { /** * Sends a cancel event to given { @ link com . nhaarman . listviewanimations . itemmanipulation . TouchEventHandler } .
 * @ param touchEventHandler the { @ code TouchEventHandler } to send the event to .
 * @ param motionEvent the { @ link MotionEvent } to base the cancel event on . */
private void sendCancelEvent ( @ Nullable final TouchEventHandler touchEventHandler , @ NonNull final MotionEvent motionEvent ) { } }

implementation: if ( touchEventHandler != null ) { MotionEvent cancelEvent = MotionEvent . obtain ( motionEvent ) ; cancelEvent . setAction ( MotionEvent . ACTION_CANCEL ) ; touchEventHandler . onTouchEvent ( cancelEvent ) ; }


signature:
public class DynamicListView { /** * Inserts an item at given index . Will show an entrance animation for the new item if the newly added item is visible .
 * Will also call { @ link Insertable # add ( int , Object ) } of the root { @ link android . widget . BaseAdapter } .
 * @ param index the index the new item should be inserted at .
 * @ param item the item to insert .
 * @ throws java . lang . IllegalStateException if the adapter that was set does not implement { @ link com . nhaarman . listviewanimations . util . Insertable } . */
public void insert ( final int index , final Object item ) { } }

implementation: if ( mAnimateAdditionAdapter == null ) { throw new IllegalStateException ( "Adapter should implement Insertable!" ) ; } mAnimateAdditionAdapter . insert ( index , item ) ;


signature:
public class DynamicListView { /** * Inserts items , starting at given index . Will show an entrance animation for the new items if the newly added items are visible .
 * Will also call { @ link Insertable # add ( int , Object ) } of the root { @ link android . widget . BaseAdapter } .
 * @ param index the starting index the new items should be inserted at .
 * @ param items the items to insert .
 * @ throws java . lang . IllegalStateException if the adapter that was set does not implement { @ link com . nhaarman . listviewanimations . util . Insertable } . */
public void insert ( final int index , final Object ... items ) { } }

implementation: if ( mAnimateAdditionAdapter == null ) { throw new IllegalStateException ( "Adapter should implement Insertable!" ) ; } mAnimateAdditionAdapter . insert ( index , items ) ;


signature:
public class DynamicListView { /** * Inserts items at given indexes . Will show an entrance animation for the new items if the newly added item is visible .
 * Will also call { @ link Insertable # add ( int , Object ) } of the root { @ link android . widget . BaseAdapter } .
 * @ param indexItemPairs the index - item pairs to insert . The first argument of the { @ code Pair } is the index , the second argument is the item .
 * @ throws java . lang . IllegalStateException if the adapter that was set does not implement { @ link com . nhaarman . listviewanimations . util . Insertable } . */
public < T > void insert ( @ NonNull final Pair < Integer , T > ... indexItemPairs ) { } }

implementation: if ( mAnimateAdditionAdapter == null ) { throw new IllegalStateException ( "Adapter should implement Insertable!" ) ; } ( ( AnimateAdditionAdapter < T > ) mAnimateAdditionAdapter ) . insert ( indexItemPairs ) ;


signature:
public class DynamicListView { /** * Starts dragging the item at given position . User must be touching this { @ code DynamicListView } .
 * This method does nothing if the drag and drop functionality is not enabled .
 * @ param position the position of the item in the adapter to start dragging . Be sure to subtract any header views .
 * @ throws java . lang . IllegalStateException if the user is not touching this { @ code DynamicListView } ,
 * or if there is no adapter set . */
public void startDragging ( final int position ) { } }

implementation:
/* We don ' t support dragging items when items are in the undo state . */
if ( mSwipeTouchListener instanceof SwipeUndoTouchListener && ( ( SwipeUndoTouchListener ) mSwipeTouchListener ) . hasPendingItems ( ) ) { return ; } if ( mDragAndDropHandler != null ) { mDragAndDropHandler . startDragging ( position ) ; }


signature:
public class DynamicListView { /** * Dismisses the { @ link android . view . View } corresponding to given position .
 * Calling this method has the same effect as manually swiping an item off the screen .
 * This method does nothing if no swipe functionality is enabled .
 * It will however throw an exception if an incompatible swipe functionality is enabled .
 * @ param position the position of the item in the { @ link android . widget . ListAdapter } . Must be visible .
 * @ throws java . lang . IllegalStateException if the { @ link com . nhaarman . listviewanimations . itemmanipulation . swipedismiss . SwipeTouchListener }
 * that is enabled does not extend { @ link com . nhaarman . listviewanimations . itemmanipulation . swipedismiss . SwipeDismissTouchListener } . */
public void dismiss ( final int position ) { } }

implementation: if ( mSwipeTouchListener != null ) { if ( mSwipeTouchListener instanceof SwipeDismissTouchListener ) { ( ( SwipeDismissTouchListener ) mSwipeTouchListener ) . dismiss ( position ) ; } else { throw new IllegalStateException ( "Enabled swipe functionality does not support dismiss" ) ; } }


signature:
public class DynamicListView { /** * Performs the undo animation and restores the original state for given { @ link android . view . View } .
 * This method does nothing if no swipe functionality is enabled .
 * It will however throw an exception if an incompatible swipe functionality is enabled .
 * @ param view the parent { @ code View } which contains both primary and undo { @ code View } s .
 * @ throws java . lang . IllegalStateException if the { @ link com . nhaarman . listviewanimations . itemmanipulation . swipedismiss . SwipeTouchListener }
 * that is enabled doe snot extend { @ link com . nhaarman . listviewanimations . itemmanipulation . swipedismiss . undo . SwipeUndoTouchListener } . */
public void undo ( @ NonNull final View view ) { } }

implementation: if ( mSwipeTouchListener != null ) { if ( mSwipeTouchListener instanceof SwipeUndoTouchListener ) { ( ( SwipeUndoTouchListener ) mSwipeTouchListener ) . undo ( view ) ; } else { throw new IllegalStateException ( "Enabled swipe functionality does not support undo" ) ; } }


signature:
public class BitmapUtils { /** * Returns a bitmap showing a screenshot of the view passed in . */
@ NonNull static Bitmap getBitmapFromView ( @ NonNull final View v ) { } }

implementation: Bitmap bitmap = Bitmap . createBitmap ( v . getMeasuredWidth ( ) , v . getMeasuredHeight ( ) , Bitmap . Config . ARGB_8888 ) ; Canvas canvas = new Canvas ( bitmap ) ; v . draw ( canvas ) ; return bitmap ;


signature:
public class Util { /** * Removes positions in { @ code dismissedPositions } from { @ code positions } , and shifts the remaining positions accordingly .
 * @ param positions the list of positions to remove from .
 * @ param dismissedPositions the list of positions to remove .
 * @ return a new { @ link java . util . Collection } instance , containing the resulting positions . */
@ NonNull static Collection < Integer > processDeletions ( @ NonNull final Collection < Integer > positions , @ NonNull final List < Integer > dismissedPositions ) { } }

implementation: Collection < Integer > result = new ArrayList < > ( positions ) ; Collections . sort ( dismissedPositions , Collections . reverseOrder ( ) ) ; Collection < Integer > newUndoPositions = new ArrayList < > ( ) ; for ( int position : dismissedPositions ) { for ( Iterator < Integer > iterator = result . iterator ( ) ; iterator . hasNext ( ) ; ) { int undoPosition = iterator . next ( ) ; if ( undoPosition > position ) { iterator . remove ( ) ; newUndoPositions . add ( undoPosition - 1 ) ; } else if ( undoPosition == position ) { iterator . remove ( ) ; } else { newUndoPositions . add ( undoPosition ) ; } } result . clear ( ) ; result . addAll ( newUndoPositions ) ; newUndoPositions . clear ( ) ; } return result ;


signature:
public class SwipeTouchListener { /** * Flings the { @ link android . view . View } corresponding to given position out of sight .
 * Calling this method has the same effect as manually swiping an item off the screen .
 * @ param position the position of the item in the { @ link android . widget . ListAdapter } . Must be visible . */
public void fling ( final int position ) { } }

implementation: int firstVisiblePosition = mListViewWrapper . getFirstVisiblePosition ( ) ; int lastVisiblePosition = mListViewWrapper . getLastVisiblePosition ( ) ; if ( position < firstVisiblePosition || position > lastVisiblePosition ) { throw new IllegalArgumentException ( "View for position " + position + " not visible!" ) ; } View downView = AdapterViewUtil . getViewForPosition ( mListViewWrapper , position ) ; if ( downView == null ) { throw new IllegalStateException ( "No view found for position " + position ) ; } flingView ( downView , position , true ) ; mActiveSwipeCount ++ ; mVirtualListCount -- ;


signature:
public class SwipeTouchListener { /** * Returns the child { @ link android . view . View } that was touched , by performing a hit test .
 * @ param motionEvent the { @ link android . view . MotionEvent } to find the { @ code View } for .
 * @ return the touched { @ code View } , or { @ code null } if none found . */
@ Nullable private View findDownView ( @ NonNull final MotionEvent motionEvent ) { } }

implementation: Rect rect = new Rect ( ) ; int childCount = mListViewWrapper . getChildCount ( ) ; int x = ( int ) motionEvent . getX ( ) ; int y = ( int ) motionEvent . getY ( ) ; View downView = null ; for ( int i = 0 ; i < childCount && downView == null ; i ++ ) { View child = mListViewWrapper . getChildAt ( i ) ; if ( child != null ) { child . getHitRect ( rect ) ; if ( rect . contains ( x , y ) ) { downView = child ; } } } return downView ;


signature:
public class SwipeTouchListener { /** * Finds out whether the item represented by given position is dismissable .
 * @ param position the position of the item .
 * @ return { @ code true } if the item is dismissable , false otherwise . */
private boolean isDismissable ( final int position ) { } }

implementation: if ( mListViewWrapper . getAdapter ( ) == null ) { return false ; } if ( mDismissableManager != null ) { long downId = mListViewWrapper . getAdapter ( ) . getItemId ( position ) ; return mDismissableManager . isDismissable ( downId , position ) ; } return true ;


signature:
public class SwipeTouchListener { /** * Flings given { @ link android . view . View } out of sight .
 * @ param view the parent { @ link android . view . View } .
 * @ param position the position of the item in the { @ link android . widget . ListAdapter } corresponding to the { @ code View } .
 * @ param flingToRight { @ code true } if the { @ code View } should be flinged to the right , { @ code false } if it should be flinged to the left . */
private void flingView ( @ NonNull final View view , final int position , final boolean flingToRight ) { } }

implementation: if ( mViewWidth < 2 ) { mViewWidth = mListViewWrapper . getListView ( ) . getWidth ( ) ; } View swipeView = getSwipeView ( view ) ; ObjectAnimator xAnimator = ObjectAnimator . ofFloat ( swipeView , TRANSLATION_X , flingToRight ? mViewWidth : - mViewWidth ) ; ObjectAnimator alphaAnimator = ObjectAnimator . ofFloat ( swipeView , ALPHA , 0 ) ; AnimatorSet animatorSet = new AnimatorSet ( ) ; animatorSet . playTogether ( xAnimator , alphaAnimator ) ; animatorSet . setDuration ( mAnimationTime ) ; animatorSet . addListener ( new FlingAnimatorListener ( view , position ) ) ; animatorSet . start ( ) ;


signature:
public class SwipeTouchListener { /** * Animates the pending { @ link android . view . View } back to its original position . */
private void restoreCurrentViewTranslation ( ) { } }

implementation: if ( mCurrentView == null ) { return ; } ObjectAnimator xAnimator = ObjectAnimator . ofFloat ( mSwipingView , TRANSLATION_X , 0 ) ; ObjectAnimator alphaAnimator = ObjectAnimator . ofFloat ( mSwipingView , ALPHA , 1 ) ; AnimatorSet animatorSet = new AnimatorSet ( ) ; animatorSet . playTogether ( xAnimator , alphaAnimator ) ; animatorSet . setDuration ( mAnimationTime ) ; animatorSet . addListener ( new RestoreAnimatorListener ( mCurrentView , mCurrentPosition ) ) ; animatorSet . start ( ) ;


signature:
public class SwipeTouchListener { /** * Resets the fields to the initial values , ready to start over . */
private void reset ( ) { } }

implementation: if ( mVelocityTracker != null ) { mVelocityTracker . recycle ( ) ; } mVelocityTracker = null ; mDownX = 0 ; mDownY = 0 ; mCurrentView = null ; mSwipingView = null ; mCurrentPosition = AdapterView . INVALID_POSITION ; mSwiping = false ; mCanDismissCurrent = false ;


signature:
public class SwipeTouchListener { /** * Restores the { @ link android . view . View } ' s { @ code alpha } and { @ code translationX } values .
 * Users of this class should call this method when recycling { @ code View } s .
 * @ param view the { @ code View } whose presentation should be restored . */
protected void restoreViewPresentation ( @ NonNull final View view ) { } }

implementation: View swipedView = getSwipeView ( view ) ; ViewHelper . setAlpha ( swipedView , 1 ) ; ViewHelper . setTranslationX ( swipedView , 0 ) ;


signature:
public class HoverDrawable { /** * Calculates the new position for this { @ code HoverDrawable } using given { @ link MotionEvent } .
 * @ param ev the { @ code MotionEvent } .
 * { @ code ev . getActionMasked ( ) } should typically equal { @ link MotionEvent # ACTION _ MOVE } . */
void handleMoveEvent ( @ NonNull final MotionEvent ev ) { } }

implementation: int top = ( int ) ( mOriginalY - mDownY + ev . getY ( ) + mScrollDistance ) ; setTop ( top ) ;


signature:
public class HoverDrawable { /** * Sets the top coordinate of this { @ code HoverDrawable } . */
void setTop ( final int top ) { } }

implementation: setBounds ( getBounds ( ) . left , top , getBounds ( ) . left + getIntrinsicWidth ( ) , top + getIntrinsicHeight ( ) ) ;


signature:
public class HoverDrawable { /** * Shifts the original y coordinates of this { @ code HoverDrawable } { code height } pixels upwards or downwards ,
 * depending on the move direction .
 * @ param height the number of pixels this { @ code HoverDrawable } should be moved . Should be positive . */
void shift ( final int height ) { } }

implementation: int shiftSize = isMovingUpwards ( ) ? - height : height ; mOriginalY += shiftSize ; mDownY += shiftSize ;


signature:
public class SwipeUndoView { /** * Sets the primary { @ link android . view . View } . Removes any existing primary { @ code View } if present . */
void setPrimaryView ( @ NonNull final View primaryView ) { } }

implementation: if ( mPrimaryView != null ) { removeView ( mPrimaryView ) ; } mPrimaryView = primaryView ; addView ( mPrimaryView ) ;


signature:
public class SwipeUndoView { /** * Sets the undo { @ link android . view . View } . Removes any existing primary { @ code View } if present , and sets the visibility of the { @ code undoView } to { @ link # GONE } . */
void setUndoView ( @ NonNull final View undoView ) { } }

implementation: if ( mUndoView != null ) { removeView ( mUndoView ) ; } mUndoView = undoView ; mUndoView . setVisibility ( GONE ) ; addView ( mUndoView ) ;


signature:
public class SwipeDismissTouchListener { /** * Animates the dismissed list item to zero - height and fires the dismiss callback when all dismissed list item animations have completed .
 * @ param view the dismissed { @ link android . view . View } . */
protected void performDismiss ( @ NonNull final View view , final int position ) { } }

implementation: mDismissedViews . add ( view ) ; mDismissedPositions . add ( position ) ; ValueAnimator animator = ValueAnimator . ofInt ( view . getHeight ( ) , 1 ) . setDuration ( mDismissAnimationTime ) ; animator . addUpdateListener ( new DismissAnimatorUpdateListener ( view ) ) ; animator . addListener ( new DismissAnimatorListener ( ) ) ; animator . start ( ) ; mActiveDismissCount ++ ;


signature:
public class SwipeDismissTouchListener { /** * If necessary , notifies the { @ link OnDismissCallback } to remove dismissed object from the adapter ,
 * and restores the { @ link android . view . View } presentations . */
protected void finalizeDismiss ( ) { } }

implementation: if ( mActiveDismissCount == 0 && getActiveSwipeCount ( ) == 0 ) { restoreViewPresentations ( mDismissedViews ) ; notifyCallback ( mDismissedPositions ) ; mDismissedViews . clear ( ) ; mDismissedPositions . clear ( ) ; }


signature:
public class SwipeDismissTouchListener { /** * Notifies the { @ link OnDismissCallback } of dismissed items .
 * @ param dismissedPositions the positions that have been dismissed . */
protected void notifyCallback ( @ NonNull final List < Integer > dismissedPositions ) { } }

implementation: if ( ! dismissedPositions . isEmpty ( ) ) { Collections . sort ( dismissedPositions , Collections . reverseOrder ( ) ) ; int [ ] dismissPositions = new int [ dismissedPositions . size ( ) ] ; int i = 0 ; for ( Integer dismissedPosition : dismissedPositions ) { dismissPositions [ i ] = dismissedPosition ; i ++ ; } mCallback . onDismiss ( getListViewWrapper ( ) . getListView ( ) , dismissPositions ) ; }


signature:
public class SwipeDismissTouchListener { /** * Restores the presentation of given { @ link android . view . View } s by calling { @ link # restoreViewPresentation ( android . view . View ) } . */
protected void restoreViewPresentations ( @ NonNull final Iterable < View > views ) { } }

implementation: for ( View view : views ) { restoreViewPresentation ( view ) ; }


signature:
public class ViewAnimator { /** * Call this method to reset animation status on all views . */
public void reset ( ) { } }

implementation: for ( int i = 0 ; i < mAnimators . size ( ) ; i ++ ) { mAnimators . get ( mAnimators . keyAt ( i ) ) . cancel ( ) ; } mAnimators . clear ( ) ; mFirstAnimatedPosition = - 1 ; mLastAnimatedPosition = - 1 ; mAnimationStartMillis = - 1 ; mShouldAnimate = true ;


signature:
public class ViewAnimator { /** * Cancels any existing animations for given View . */
void cancelExistingAnimation ( @ NonNull final View view ) { } }

implementation: int hashCode = view . hashCode ( ) ; Animator animator = mAnimators . get ( hashCode ) ; if ( animator != null ) { animator . end ( ) ; mAnimators . remove ( hashCode ) ; }


signature:
public class ViewAnimator { /** * Animates given View if necessary .
 * @ param position the position of the item the View represents .
 * @ param view the View that should be animated . */
public void animateViewIfNecessary ( final int position , @ NonNull final View view , @ NonNull final Animator [ ] animators ) { } }

implementation: if ( mShouldAnimate && position > mLastAnimatedPosition ) { if ( mFirstAnimatedPosition == - 1 ) { mFirstAnimatedPosition = position ; } animateView ( position , view , animators ) ; mLastAnimatedPosition = position ; }


signature:
public class ViewAnimator { /** * Animates given View .
 * @ param view the View that should be animated . */
private void animateView ( final int position , @ NonNull final View view , @ NonNull final Animator [ ] animators ) { } }

implementation: if ( mAnimationStartMillis == - 1 ) { mAnimationStartMillis = SystemClock . uptimeMillis ( ) ; } ViewHelper . setAlpha ( view , 0 ) ; AnimatorSet set = new AnimatorSet ( ) ; set . playTogether ( animators ) ; set . setStartDelay ( calculateAnimationDelay ( position ) ) ; set . setDuration ( mAnimationDurationMillis ) ; set . start ( ) ; mAnimators . put ( view . hashCode ( ) , set ) ;


signature:
public class ViewAnimator { /** * Returns the delay in milliseconds after which animation for View with position mLastAnimatedPosition + 1 should start . */
@ SuppressLint ( "NewApi" ) private int calculateAnimationDelay ( final int position ) { } }

implementation: int delay ; int lastVisiblePosition = mListViewWrapper . getLastVisiblePosition ( ) ; int firstVisiblePosition = mListViewWrapper . getFirstVisiblePosition ( ) ; int numberOfItemsOnScreen = lastVisiblePosition - firstVisiblePosition ; int numberOfAnimatedItems = position - 1 - mFirstAnimatedPosition ; if ( numberOfItemsOnScreen + 1 < numberOfAnimatedItems ) { delay = mAnimationDelayMillis ; if ( mListViewWrapper . getListView ( ) instanceof GridView && Build . VERSION . SDK_INT >= Build . VERSION_CODES . HONEYCOMB ) { int numColumns = ( ( GridView ) mListViewWrapper . getListView ( ) ) . getNumColumns ( ) ; delay += mAnimationDelayMillis * ( position % numColumns ) ; } } else { int delaySinceStart = ( position - mFirstAnimatedPosition ) * mAnimationDelayMillis ; delay = Math . max ( 0 , ( int ) ( - SystemClock . uptimeMillis ( ) + mAnimationStartMillis + mInitialDelayMillis + delaySinceStart ) ) ; } return delay ;


signature:
public class ViewAnimator { /** * Returns a Parcelable object containing the AnimationAdapter ' s current dynamic state . */
@ NonNull public Parcelable onSaveInstanceState ( ) { } }

implementation: Bundle bundle = new Bundle ( ) ; bundle . putInt ( SAVEDINSTANCESTATE_FIRSTANIMATEDPOSITION , mFirstAnimatedPosition ) ; bundle . putInt ( SAVEDINSTANCESTATE_LASTANIMATEDPOSITION , mLastAnimatedPosition ) ; bundle . putBoolean ( SAVEDINSTANCESTATE_SHOULDANIMATE , mShouldAnimate ) ; return bundle ;


signature:
public class ViewAnimator { /** * Restores this AnimationAdapter ' s state .
 * @ param parcelable the Parcelable object previously returned by { @ link # onSaveInstanceState ( ) } . */
public void onRestoreInstanceState ( @ Nullable final Parcelable parcelable ) { } }

implementation: if ( parcelable instanceof Bundle ) { Bundle bundle = ( Bundle ) parcelable ; mFirstAnimatedPosition = bundle . getInt ( SAVEDINSTANCESTATE_FIRSTANIMATEDPOSITION ) ; mLastAnimatedPosition = bundle . getInt ( SAVEDINSTANCESTATE_LASTANIMATEDPOSITION ) ; mShouldAnimate = bundle . getBoolean ( SAVEDINSTANCESTATE_SHOULDANIMATE ) ; }


signature:
public class AdapterViewUtil { /** * Returns the position within the adapter ' s dataset for the view , where view is an adapter item or a descendant of an adapter item .
 * Unlike { @ link AdapterView # getPositionForView ( android . view . View ) } , returned position will reflect the position of the item given view is representing ,
 * by subtracting the header views count .
 * @ param listViewWrapper the IListViewWrapper wrapping the ListView containing the view .
 * @ param view an adapter item or a descendant of an adapter item . This must be visible in given AdapterView at the time of the call .
 * @ return the position of the item in the AdapterView represented by given view , or { @ link AdapterView # INVALID _ POSITION } if the view does not
 * correspond to a list item ( or it is not visible ) . */
public static int getPositionForView ( @ NonNull final ListViewWrapper listViewWrapper , @ NonNull final View view ) { } }

implementation: return listViewWrapper . getPositionForView ( view ) - listViewWrapper . getHeaderViewsCount ( ) ;


signature:
public class AdapterViewUtil { /** * Returns the position within the adapter ' s dataset for the view , where view is an adapter item or a descendant of an adapter item .
 * Unlike { @ link AdapterView # getPositionForView ( android . view . View ) } , returned position will reflect the position of the item given view is representing ,
 * by subtracting the header views count .
 * @ param absListView the ListView containing the view .
 * @ param view an adapter item or a descendant of an adapter item . This must be visible in given AdapterView at the time of the call .
 * @ return the position of the item in the AdapterView represented by given view , or { @ link AdapterView # INVALID _ POSITION } if the view does not
 * correspond to a list item ( or it is not visible ) . */
public static int getPositionForView ( @ NonNull final AbsListView absListView , @ NonNull final View view ) { } }

implementation: int position = absListView . getPositionForView ( view ) ; if ( absListView instanceof ListView ) { position -= ( ( ListView ) absListView ) . getHeaderViewsCount ( ) ; } return position ;


signature:
public class AdapterViewUtil { /** * Returns the { @ link View } that represents the item for given position .
 * @ param listViewWrapper the { @ link ListViewWrapper } wrapping the ListView that should be examined
 * @ param position the position for which the { @ code View } should be returned .
 * @ return the { @ code View } , or { @ code null } if the position is not currently visible . */
@ Nullable public static View getViewForPosition ( @ NonNull final ListViewWrapper listViewWrapper , final int position ) { } }

implementation: int childCount = listViewWrapper . getChildCount ( ) ; View downView = null ; for ( int i = 0 ; i < childCount && downView == null ; i ++ ) { View child = listViewWrapper . getChildAt ( i ) ; if ( child != null && getPositionForView ( listViewWrapper , child ) == position ) { downView = child ; } } return downView ;


signature:
public class AdapterViewUtil { /** * Returns the { @ link View } that represents the item for given position .
 * @ param absListView the ListView that should be examined
 * @ param position the position for which the { @ code View } should be returned .
 * @ return the { @ code View } , or { @ code null } if the position is not currently visible . */
@ Nullable public static View getViewForPosition ( @ NonNull final AbsListView absListView , final int position ) { } }

implementation: int childCount = absListView . getChildCount ( ) ; View downView = null ; for ( int i = 0 ; i < childCount && downView == null ; i ++ ) { View child = absListView . getChildAt ( i ) ; if ( child != null && getPositionForView ( absListView , child ) == position ) { downView = child ; } } return downView ;


signature:
public class BaseAdapterDecorator { /** * Returns the root { @ link android . widget . BaseAdapter } this { @ code BaseAdapterDecorator } decorates . */
@ NonNull protected BaseAdapter getRootAdapter ( ) { } }

implementation: BaseAdapter adapter = mDecoratedBaseAdapter ; while ( adapter instanceof BaseAdapterDecorator ) { adapter = ( ( BaseAdapterDecorator ) adapter ) . getDecoratedBaseAdapter ( ) ; } return adapter ;


signature:
public class BaseAdapterDecorator { /** * Alternative to { @ link # setAbsListView ( android . widget . AbsListView ) } . Sets the { @ link com . nhaarman . listviewanimations . util . ListViewWrapper } which contains the ListView
 * this adapter will be bound to . Call this method before setting this adapter to the ListView . Also propagates to the decorated { @ code BaseAdapter } if applicable . */
@ Override public void setListViewWrapper ( @ NonNull final ListViewWrapper listViewWrapper ) { } }

implementation: mListViewWrapper = listViewWrapper ; if ( mDecoratedBaseAdapter instanceof ListViewWrapperSetter ) { ( ( ListViewWrapperSetter ) mDecoratedBaseAdapter ) . setListViewWrapper ( listViewWrapper ) ; }


signature:
public class SwipeUndoTouchListener { /** * Animates the dismissed list item to zero - height and fires the dismiss callback when all dismissed list item animations have completed .
 * @ param view the dismissed { @ link android . view . View } . */
@ Override protected void performDismiss ( @ NonNull final View view , final int position ) { } }

implementation: super . performDismiss ( view , position ) ; mDismissedViews . add ( view ) ; mDismissedPositions . add ( position ) ; mCallback . onDismiss ( view , position ) ;


signature:
public class SwipeUndoTouchListener { /** * Sets the visibility of the primary { @ link android . view . View } to { @ link android . view . View # GONE } , and animates the undo { @ code View } in to view .
 * @ param view the parent { @ code View } which contains both primary and undo { @ code View } s . */
private void showUndoView ( @ NonNull final View view ) { } }

implementation: mCallback . getPrimaryView ( view ) . setVisibility ( View . GONE ) ; View undoView = mCallback . getUndoView ( view ) ; undoView . setVisibility ( View . VISIBLE ) ; ObjectAnimator . ofFloat ( undoView , ALPHA , 0f , 1f ) . start ( ) ;


signature:
public class SwipeUndoTouchListener { /** * Sets the visibility of the primary { @ link android . view . View } to { @ link android . view . View # VISIBLE } , and that of the undo { @ code View } to { @ link android . view . View # GONE } .
 * @ param view the parent { @ code View } which contains both primary and undo { @ code View } s . */
private void hideUndoView ( @ NonNull final View view ) { } }

implementation: mCallback . getPrimaryView ( view ) . setVisibility ( View . VISIBLE ) ; mCallback . getUndoView ( view ) . setVisibility ( View . GONE ) ;


signature:
public class SwipeUndoTouchListener { /** * If necessary , notifies the { @ link UndoCallback } to remove dismissed object from the adapter ,
 * and restores the { @ link android . view . View } presentations . */
@ Override protected void finalizeDismiss ( ) { } }

implementation: if ( getActiveDismissCount ( ) == 0 && getActiveSwipeCount ( ) == 0 ) { restoreViewPresentations ( mDismissedViews ) ; notifyCallback ( mDismissedPositions ) ; Collection < Integer > newUndoPositions = Util . processDeletions ( mUndoPositions , mDismissedPositions ) ; mUndoPositions . clear ( ) ; mUndoPositions . addAll ( newUndoPositions ) ; mDismissedViews . clear ( ) ; mDismissedPositions . clear ( ) ; }


signature:
public class SwipeUndoTouchListener { /** * Performs the undo animation and restores the original state for given { @ link android . view . View } .
 * @ param view the parent { @ code View } which contains both primary and undo { @ code View } s . */
public void undo ( @ NonNull final View view ) { } }

implementation: int position = AdapterViewUtil . getPositionForView ( getListViewWrapper ( ) , view ) ; mUndoPositions . remove ( position ) ; View primaryView = mCallback . getPrimaryView ( view ) ; View undoView = mCallback . getUndoView ( view ) ; primaryView . setVisibility ( View . VISIBLE ) ; ObjectAnimator undoAlphaAnimator = ObjectAnimator . ofFloat ( undoView , ALPHA , 1f , 0f ) ; ObjectAnimator primaryAlphaAnimator = ObjectAnimator . ofFloat ( primaryView , ALPHA , 0f , 1f ) ; ObjectAnimator primaryXAnimator = ObjectAnimator . ofFloat ( primaryView , TRANSLATION_X , primaryView . getWidth ( ) , 0f ) ; AnimatorSet animatorSet = new AnimatorSet ( ) ; animatorSet . playTogether ( undoAlphaAnimator , primaryAlphaAnimator , primaryXAnimator ) ; animatorSet . addListener ( new UndoAnimatorListener ( undoView ) ) ; animatorSet . start ( ) ; mCallback . onUndo ( view , position ) ;


signature:
public class SwipeDismissAdapter { /** * Sets the { @ link com . nhaarman . listviewanimations . itemmanipulation . swipedismiss . DismissableManager } to specify which views can or cannot be swiped .
 * @ param dismissableManager { @ code null } for no restrictions . */
public void setDismissableManager ( @ Nullable final DismissableManager dismissableManager ) { } }

implementation: if ( mDismissTouchListener == null ) { throw new IllegalStateException ( "You must call setAbsListView() first." ) ; } mDismissTouchListener . setDismissableManager ( dismissableManager ) ;


signature:
public class AnimatorUtil { /** * Merges given Animators into one array . */
@ NonNull public static Animator [ ] concatAnimators ( @ NonNull final Animator [ ] childAnimators , @ NonNull final Animator [ ] animators , @ NonNull final Animator alphaAnimator ) { } }

implementation: Animator [ ] allAnimators = new Animator [ childAnimators . length + animators . length + 1 ] ; int i ; for ( i = 0 ; i < childAnimators . length ; ++ i ) { allAnimators [ i ] = childAnimators [ i ] ; } for ( Animator animator : animators ) { allAnimators [ i ] = animator ; ++ i ; } allAnimators [ allAnimators . length - 1 ] = alphaAnimator ; return allAnimators ;


signature:
public class CORSFilter { /** * Handles a CORS request of type { @ link CORSRequestType } . SIMPLE .
 * @ param request
 * The { @ link HttpServletRequest } object .
 * @ param response
 * The { @ link HttpServletResponse } object .
 * @ param filterChain
 * The { @ link FilterChain } object .
 * @ throws IOException
 * @ throws ServletException
 * @ see < a href = " http : / / www . w3 . org / TR / cors / # resource - requests " > Simple
 * Cross - Origin Request , Actual Request , and Redirects < / a > */
public void handleSimpleCORS ( final HttpServletRequest request , final HttpServletResponse response , final FilterChain filterChain ) throws IOException , ServletException { } }

implementation:
CORSFilter . CORSRequestType requestType = checkRequestType ( request ) ; if ( ! ( requestType == CORSFilter . CORSRequestType . SIMPLE || requestType == CORSFilter . CORSRequestType . ACTUAL ) ) { String message = "Expects a HttpServletRequest object of type " + CORSFilter . CORSRequestType . SIMPLE + " or " + CORSFilter . CORSRequestType . ACTUAL ; throw new IllegalArgumentException ( message ) ; } final String origin = request . getHeader ( CORSFilter . REQUEST_HEADER_ORIGIN ) ; final String method = request . getMethod ( ) ; // Section 6.1.2
if ( ! isOriginAllowed ( origin ) ) { handleInvalidCORS ( request , response , filterChain ) ; return ; } if ( ! allowedHttpMethods . contains ( method ) ) { handleInvalidCORS ( request , response , filterChain ) ; return ; } // Section 6.1.3
// Add a single Access - Control - Allow - Origin header .
if ( anyOriginAllowed && ! supportsCredentials ) { // If resource doesn ' t support credentials and if any origin is
// allowed
// to make CORS request , return header with ' * ' .
response . addHeader ( CORSFilter . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN , "*" ) ; } else { // If the resource supports credentials add a single
// Access - Control - Allow - Origin header , with the value of the Origin
// header as value .
response . addHeader ( CORSFilter . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN , origin ) ; } // Section 6.1.3
// If the resource supports credentials , add a single
// Access - Control - Allow - Credentials header with the case - sensitive
// string " true " as value .
if ( supportsCredentials ) { response . addHeader ( CORSFilter . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS , "true" ) ; } // Section 6.1.4
// If the list of exposed headers is not empty add one or more
// Access - Control - Expose - Headers headers , with as values the header
// field names given in the list of exposed headers .
if ( ( exposedHeaders != null ) && ( exposedHeaders . size ( ) > 0 ) ) { String exposedHeadersString = join ( exposedHeaders , "," ) ; response . addHeader ( CORSFilter . RESPONSE_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS , exposedHeadersString ) ; } // Forward the request down the filter chain .
filterChain . doFilter ( request , response ) ;


signature:
public class CORSFilter { /** * Handles CORS pre - flight request .
 * @ param request
 * The { @ link HttpServletRequest } object .
 * @ param response
 * The { @ link HttpServletResponse } object .
 * @ param filterChain
 * The { @ link FilterChain } object .
 * @ throws IOException
 * @ throws ServletException */
public void handlePreflightCORS ( final HttpServletRequest request , final HttpServletResponse response , final FilterChain filterChain ) throws IOException , ServletException { } }

implementation:
CORSRequestType requestType = checkRequestType ( request ) ; if ( requestType != CORSRequestType . PRE_FLIGHT ) { throw new IllegalArgumentException ( "Expects a HttpServletRequest object of type " + CORSRequestType . PRE_FLIGHT . name ( ) . toLowerCase ( ) ) ; } final String origin = request . getHeader ( CORSFilter . REQUEST_HEADER_ORIGIN ) ; // Section 6.2.2
if ( ! isOriginAllowed ( origin ) ) { handleInvalidCORS ( request , response , filterChain ) ; return ; } // Section 6.2.3
String accessControlRequestMethod = request . getHeader ( CORSFilter . REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD ) ; if ( accessControlRequestMethod == null || ( ! HTTP_METHODS . contains ( accessControlRequestMethod . trim ( ) ) ) ) { handleInvalidCORS ( request , response , filterChain ) ; return ; } else { accessControlRequestMethod = accessControlRequestMethod . trim ( ) ; } // Section 6.2.4
String accessControlRequestHeadersHeader = request . getHeader ( CORSFilter . REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS ) ; List < String > accessControlRequestHeaders = new LinkedList < String > ( ) ; if ( accessControlRequestHeadersHeader != null && ! accessControlRequestHeadersHeader . trim ( ) . isEmpty ( ) ) { String [ ] headers = accessControlRequestHeadersHeader . trim ( ) . split ( "," ) ; for ( String header : headers ) { accessControlRequestHeaders . add ( header . trim ( ) . toLowerCase ( ) ) ; } } // Section 6.2.5
if ( ! allowedHttpMethods . contains ( accessControlRequestMethod ) ) { handleInvalidCORS ( request , response , filterChain ) ; return ; } // Section 6.2.6
if ( ! accessControlRequestHeaders . isEmpty ( ) ) { for ( String header : accessControlRequestHeaders ) { if ( ! allowedHttpHeaders . contains ( header ) ) { handleInvalidCORS ( request , response , filterChain ) ; return ; } } } // Section 6.2.7
if ( supportsCredentials ) { response . addHeader ( CORSFilter . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN , origin ) ; response . addHeader ( CORSFilter . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS , "true" ) ; } else { if ( anyOriginAllowed ) { response . addHeader ( CORSFilter . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN , "*" ) ; } else { response . addHeader ( CORSFilter . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN , origin ) ; } } // Section 6.2.8
if ( preflightMaxAge > 0 ) { response . addHeader ( CORSFilter . RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE , String . valueOf ( preflightMaxAge ) ) ; } // Section 6.2.9
response . addHeader ( CORSFilter . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS , accessControlRequestMethod ) ; // Section 6.2.10
if ( ( allowedHttpHeaders != null ) && ( ! allowedHttpHeaders . isEmpty ( ) ) ) { response . addHeader ( CORSFilter . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS , join ( allowedHttpHeaders , "," ) ) ; } // Do not forward the request down the filter chain .


signature:
public class CORSFilter { /** * Handles a request , that ' s not a CORS request , but is a valid request i . e .
 * it is not a cross - origin request . This implementation , just forwards the
 * request down the filter chain .
 * @ param request
 * The { @ link HttpServletRequest } object .
 * @ param response
 * The { @ link HttpServletResponse } object .
 * @ param filterChain
 * The { @ link FilterChain } object .
 * @ throws IOException
 * @ throws ServletException */
public void handleNonCORS ( final HttpServletRequest request , final HttpServletResponse response , final FilterChain filterChain ) throws IOException , ServletException { } }

implementation:
// Let request pass .
filterChain . doFilter ( request , response ) ;


signature:
public class CORSFilter { /** * Handles a CORS request that violates specification .
 * @ param request
 * The { @ link HttpServletRequest } object .
 * @ param response
 * The { @ link HttpServletResponse } object .
 * @ param filterChain
 * The { @ link FilterChain } object .
 * @ throws IOException
 * @ throws ServletException */
public void handleInvalidCORS ( final HttpServletRequest request , final HttpServletResponse response , final FilterChain filterChain ) { } }

implementation: String origin = request . getHeader ( CORSFilter . REQUEST_HEADER_ORIGIN ) ; String method = request . getMethod ( ) ; String accessControlRequestHeaders = request . getHeader ( REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS ) ; String message = "Invalid CORS request; Origin=" + origin + ";Method=" + method ; if ( accessControlRequestHeaders != null ) { message = message + ";Access-Control-Request-Headers=" + accessControlRequestHeaders ; } response . setContentType ( "text/plain" ) ; response . setStatus ( HttpServletResponse . SC_FORBIDDEN ) ; response . resetBuffer ( ) ; log ( message ) ;


signature:
public class CORSFilter { /** * Takes a comma separated list and returns a Set < String > .
 * @ param data
 * A comma separated list of strings .
 * @ return Set < String > */
private Set < String > parseStringToSet ( final String data ) { } }

implementation: String [ ] splits ; if ( data != null && data . length ( ) > 0 ) { splits = data . split ( "," ) ; } else { splits = new String [ ] { } ; } Set < String > set = new HashSet < String > ( ) ; if ( splits . length > 0 ) { for ( String split : splits ) { set . add ( split . trim ( ) ) ; } } return set ;


signature:
public class NonEmptyVirtualStorage { /** * throws a NonEmptyException exception when number is greater than 0 */
@ Override public void addStreamOfLiteralWords ( Buffer buffer , int start , int number ) { } }

implementation: for ( int x = start ; x < start + number ; ++ x ) if ( buffer . getWord ( x ) != 0 ) throw nonEmptyException ;


signature:
public class FastAggregation { /** * Compute the and aggregate using a temporary uncompressed bitmap .
 * This function does not seek to match the " sizeinbits " attributes
 * of the input bitmaps .
 * @ param bitmaps the source bitmaps
 * @ param bufSize buffer size used during the computation in 64 - bit
 * words ( per input bitmap )
 * @ return the or aggregate . */
public static EWAHCompressedBitmap bufferedand ( final int bufSize , final EWAHCompressedBitmap ... bitmaps ) { } }

implementation: EWAHCompressedBitmap answer = new EWAHCompressedBitmap ( ) ; bufferedandWithContainer ( answer , bufSize , bitmaps ) ; return answer ;


signature:
public class FastAggregation { /** * Compute the and aggregate using a temporary uncompressed bitmap .
 * This function does not seek to match the " sizeinbits " attributes
 * of the input bitmaps .
 * @ param container where the aggregate is written
 * @ param bufSize buffer size used during the computation in 64 - bit
 * words ( per input bitmap )
 * @ param bitmaps the source bitmaps */
public static void bufferedandWithContainer ( final BitmapStorage container , final int bufSize , final EWAHCompressedBitmap ... bitmaps ) { } }

implementation: java . util . LinkedList < IteratingBufferedRunningLengthWord > al = new java . util . LinkedList < IteratingBufferedRunningLengthWord > ( ) ; for ( EWAHCompressedBitmap bitmap : bitmaps ) { al . add ( new IteratingBufferedRunningLengthWord ( bitmap ) ) ; } long [ ] hardbitmap = new long [ bufSize * bitmaps . length ] ; for ( IteratingRLW i : al ) if ( i . size ( ) == 0 ) { al . clear ( ) ; break ; } while ( ! al . isEmpty ( ) ) { Arrays . fill ( hardbitmap , ~ 0l ) ; long effective = Integer . MAX_VALUE ; for ( IteratingRLW i : al ) { int eff = IteratorAggregation . inplaceand ( hardbitmap , i ) ; if ( eff < effective ) effective = eff ; } for ( int k = 0 ; k < effective ; ++ k ) container . addWord ( hardbitmap [ k ] ) ; for ( IteratingRLW i : al ) if ( i . size ( ) == 0 ) { al . clear ( ) ; break ; } }


signature:
public class FastAggregation { /** * Compute the or aggregate using a temporary uncompressed bitmap .
 * @ param bitmaps the source bitmaps
 * @ param bufSize buffer size used during the computation in 64 - bit
 * words
 * @ return the or aggregate . */
public static EWAHCompressedBitmap bufferedor ( final int bufSize , final EWAHCompressedBitmap ... bitmaps ) { } }

implementation: EWAHCompressedBitmap answer = new EWAHCompressedBitmap ( ) ; bufferedorWithContainer ( answer , bufSize , bitmaps ) ; return answer ;


signature:
public class FastAggregation { /** * Compute the xor aggregate using a temporary uncompressed bitmap .
 * @ param bitmaps the source bitmaps
 * @ param bufSize buffer size used during the computation in 64 - bit
 * words
 * @ return the xor aggregate . */
public static EWAHCompressedBitmap bufferedxor ( final int bufSize , final EWAHCompressedBitmap ... bitmaps ) { } }

implementation: EWAHCompressedBitmap answer = new EWAHCompressedBitmap ( ) ; bufferedxorWithContainer ( answer , bufSize , bitmaps ) ; return answer ;


signature:
public class FastAggregation { /** * Uses a priority queue to compute the or aggregate .
 * This algorithm runs in linearithmic time ( O ( n log n ) ) with respect to the number of bitmaps .
 * @ param < T > a class extending LogicalElement ( like a compressed
 * bitmap )
 * @ param bitmaps bitmaps to be aggregated
 * @ return the or aggregate */
@ SuppressWarnings ( { } }

implementation: "rawtypes" , "unchecked" } ) public static < T extends LogicalElement > T or ( T ... bitmaps ) { PriorityQueue < T > pq = new PriorityQueue < T > ( bitmaps . length , new Comparator < T > ( ) { @ Override public int compare ( T a , T b ) { return a . sizeInBytes ( ) - b . sizeInBytes ( ) ; } } ) ; Collections . addAll ( pq , bitmaps ) ; while ( pq . size ( ) > 1 ) { T x1 = pq . poll ( ) ; T x2 = pq . poll ( ) ; pq . add ( ( T ) x1 . or ( x2 ) ) ; } return pq . poll ( ) ;


signature:
public class FastAggregation { /** * Uses a priority queue to compute the or aggregate .
 * The content of the container is overwritten .
 * This algorithm runs in linearithmic time ( O ( n log n ) ) with respect to the number of bitmaps .
 * @ param container where we write the result
 * @ param bitmaps to be aggregated */
public static void orToContainer ( final BitmapStorage container , final EWAHCompressedBitmap ... bitmaps ) { } }

implementation: if ( bitmaps . length < 2 ) throw new IllegalArgumentException ( "We need at least two bitmaps" ) ; PriorityQueue < EWAHCompressedBitmap > pq = new PriorityQueue < EWAHCompressedBitmap > ( bitmaps . length , new Comparator < EWAHCompressedBitmap > ( ) { @ Override public int compare ( EWAHCompressedBitmap a , EWAHCompressedBitmap b ) { return a . sizeInBytes ( ) - b . sizeInBytes ( ) ; } } ) ; Collections . addAll ( pq , bitmaps ) ; while ( pq . size ( ) > 2 ) { EWAHCompressedBitmap x1 = pq . poll ( ) ; EWAHCompressedBitmap x2 = pq . poll ( ) ; pq . add ( x1 . or ( x2 ) ) ; } pq . poll ( ) . orToContainer ( pq . poll ( ) , container ) ;


signature:
public class FastAggregation { /** * Simple algorithm that computes the OR aggregate .
 * @ param bitmaps input bitmaps
 * @ return new bitmap containing the aggregate */
public static EWAHCompressedBitmap or ( final EWAHCompressedBitmap ... bitmaps ) { } }

implementation: PriorityQueue < EWAHCompressedBitmap > pq = new PriorityQueue < EWAHCompressedBitmap > ( bitmaps . length , new Comparator < EWAHCompressedBitmap > ( ) { @ Override public int compare ( EWAHCompressedBitmap a , EWAHCompressedBitmap b ) { return a . sizeInBytes ( ) - b . sizeInBytes ( ) ; } } ) ; Collections . addAll ( pq , bitmaps ) ; if ( pq . isEmpty ( ) ) return new EWAHCompressedBitmap ( ) ; while ( pq . size ( ) > 1 ) { EWAHCompressedBitmap x1 = pq . poll ( ) ; EWAHCompressedBitmap x2 = pq . poll ( ) ; pq . add ( x1 . or ( x2 ) ) ; } return pq . poll ( ) ;


signature:
public class FastAggregation { /** * Simple algorithm that computes the OR aggregate .
 * @ param bitmaps input bitmaps
 * @ return new bitmap containing the aggregate */
public static EWAHCompressedBitmap or ( final Iterator < EWAHCompressedBitmap > bitmaps ) { } }

implementation: PriorityQueue < EWAHCompressedBitmap > pq = new PriorityQueue < EWAHCompressedBitmap > ( 32 , new Comparator < EWAHCompressedBitmap > ( ) { @ Override public int compare ( EWAHCompressedBitmap a , EWAHCompressedBitmap b ) { return a . sizeInBytes ( ) - b . sizeInBytes ( ) ; } } ) ; while ( bitmaps . hasNext ( ) ) pq . add ( bitmaps . next ( ) ) ; if ( pq . isEmpty ( ) ) return new EWAHCompressedBitmap ( ) ; while ( pq . size ( ) > 1 ) { EWAHCompressedBitmap x1 = pq . poll ( ) ; EWAHCompressedBitmap x2 = pq . poll ( ) ; pq . add ( x1 . or ( x2 ) ) ; } return pq . poll ( ) ;


signature:
public class IteratorUtil { /** * Generate a bitmap from an iterator .
 * @ param i iterator we wish to materialize
 * @ param c where we write */
public static void materialize ( final IteratingRLW i , final BitmapStorage c ) { } }

implementation: while ( true ) { if ( i . getRunningLength ( ) > 0 ) { c . addStreamOfEmptyWords ( i . getRunningBit ( ) , i . getRunningLength ( ) ) ; } int il = i . getNumberOfLiteralWords ( ) ; for ( int k = 0 ; k < il ; ++ k ) c . addWord ( i . getLiteralWordAt ( k ) ) ; if ( ! i . next ( ) ) break ; }


signature:
public class IteratorUtil { /** * Turn an iterator into a bitmap .
 * @ param i iterator we wish to materialize
 * @ param c where we write
 * @ param max maximum number of words we wish to materialize
 * @ return how many words were actually materialized */
public static long materialize ( final IteratingRLW i , final BitmapStorage c , long max ) { } }

implementation: final long origMax = max ; while ( true ) { if ( i . getRunningLength ( ) > 0 ) { long L = i . getRunningLength ( ) ; if ( L > max ) L = max ; c . addStreamOfEmptyWords ( i . getRunningBit ( ) , L ) ; max -= L ; } long L = i . getNumberOfLiteralWords ( ) ; for ( int k = 0 ; k < L ; ++ k ) c . addWord ( i . getLiteralWordAt ( k ) ) ; if ( max > 0 ) { if ( ! i . next ( ) ) break ; } else break ; } return origMax - max ;


signature:
public class IteratorUtil { /** * Turn an iterator into a bitmap .
 * This can be used to effectively clone a bitmap in the following
 * manner :
 * < code >
 * EWAHCompressedBitmap n = IteratorUtil . materialize ( bitmap . getIteratingRLW ( ) ) ) ;
 * n . setSizeInBitsWithinLastWord ( bitmap . sizeInBits ( ) ) ;
 * < / code >
 * @ param i iterator we wish to materialize
 * @ return materialized version of the iterator */
public static EWAHCompressedBitmap materialize ( final IteratingRLW i ) { } }

implementation: EWAHCompressedBitmap ewah = new EWAHCompressedBitmap ( ) ; materialize ( i , ewah ) ; return ewah ;


signature:
public class PriorityQ { /** * Remove the element on top of the heap
 * @ return the element being removed */
public T poll ( ) { } }

implementation: T ans = this . a [ 1 ] ; this . a [ 1 ] = this . a [ this . lastIndex -- ] ; percolateDown ( 1 ) ; return ans ;


signature:
public class UpdateableBitmapFunction { /** * Goes through the literals .
 * @ return an iterator */
public final Iterable < EWAHPointer > getLiterals ( ) { } }

implementation: return new Iterable < EWAHPointer > ( ) { @ Override public Iterator < EWAHPointer > iterator ( ) { return new Iterator < EWAHPointer > ( ) { int k = UpdateableBitmapFunction . this . litwlist . nextSetBit ( 0 ) ; @ Override public boolean hasNext ( ) { return this . k >= 0 ; } @ Override public EWAHPointer next ( ) { EWAHPointer answer = UpdateableBitmapFunction . this . rw [ this . k ] ; this . k = UpdateableBitmapFunction . this . litwlist . nextSetBit ( this . k + 1 ) ; return answer ; } @ Override public void remove ( ) { throw new RuntimeException ( "N/A" ) ; } } ; } } ;


signature:
public class IteratorAggregation { /** * Aggregate the iterators using a bitmap buffer .
 * @ param al set of iterators to aggregate
 * @ param bufSize size of the internal buffer used by the iterator in
 * 64 - bit words ( per input iterator )
 * @ return and aggregate */
public static IteratingRLW bufferedand ( final int bufSize , final IteratingRLW ... al ) { } }

implementation: if ( al . length == 0 ) throw new IllegalArgumentException ( "Need at least one iterator" ) ; if ( al . length == 1 ) return al [ 0 ] ; final LinkedList < IteratingRLW > basell = new LinkedList < IteratingRLW > ( ) ; Collections . addAll ( basell , al ) ; return new BufferedIterator ( new BufferedAndIterator ( basell , bufSize ) ) ;


signature:
public class IteratorAggregation { /** * Aggregate the iterators using a bitmap buffer .
 * @ param al iterators to aggregate
 * @ param bufSize size of the internal buffer used by the iterator in
 * 64 - bit words
 * @ return or aggregate */
public static IteratingRLW bufferedor ( final int bufSize , final IteratingRLW ... al ) { } }

implementation: if ( al . length == 0 ) throw new IllegalArgumentException ( "Need at least one iterator" ) ; if ( al . length == 1 ) return al [ 0 ] ; final LinkedList < IteratingRLW > basell = new LinkedList < IteratingRLW > ( ) ; Collections . addAll ( basell , al ) ; return new BufferedIterator ( new BufferedORIterator ( basell , bufSize ) ) ;


signature:
public class IteratorAggregation { /** * Aggregate the iterators using a bitmap buffer .
 * @ param al iterators to aggregate
 * @ param bufSize size of the internal buffer used by the iterator in 64 - bit words
 * @ return xor aggregate */
public static IteratingRLW bufferedxor ( final int bufSize , final IteratingRLW ... al ) { } }

implementation: if ( al . length == 0 ) throw new IllegalArgumentException ( "Need at least one iterator" ) ; if ( al . length == 1 ) return al [ 0 ] ; final LinkedList < IteratingRLW > basell = new LinkedList < IteratingRLW > ( ) ; Collections . addAll ( basell , al ) ; return new BufferedIterator ( new BufferedXORIterator ( basell , bufSize ) ) ;


signature:
public class IteratorAggregation { /** * Write out the content of the iterator , but as if it were all zeros .
 * @ param container where we write
 * @ param i the iterator */
protected static void dischargeAsEmpty ( final BitmapStorage container , final IteratingRLW i ) { } }

implementation: while ( i . size ( ) > 0 ) { container . addStreamOfEmptyWords ( false , i . size ( ) ) ; i . next ( ) ; }


signature:
public class IteratorAggregation { /** * Write out up to max words , returns how many were written
 * @ param container target for writes
 * @ param i source of data
 * @ param max maximal number of writes
 * @ return how many written */
protected static long discharge ( final BitmapStorage container , IteratingRLW i , long max ) { } }

implementation: long counter = 0 ; while ( i . size ( ) > 0 && counter < max ) { long l1 = i . getRunningLength ( ) ; if ( l1 > 0 ) { if ( l1 + counter > max ) l1 = max - counter ; container . addStreamOfEmptyWords ( i . getRunningBit ( ) , l1 ) ; counter += l1 ; } long l = i . getNumberOfLiteralWords ( ) ; if ( l + counter > max ) l = max - counter ; for ( int k = 0 ; k < l ; ++ k ) { container . addWord ( i . getLiteralWordAt ( k ) ) ; } counter += l ; i . discardFirstWords ( l + l1 ) ; } return counter ;


signature:
public class LongArray { /** * Resizes the buffer if the number of words to add exceeds the buffer capacity .
 * @ param number the number of words to add */
private void resizeBuffer ( int number ) { } }

implementation: int size = newSizeInWords ( number ) ; if ( size >= this . buffer . length ) { long oldBuffer [ ] = this . buffer ; this . buffer = new long [ size ] ; System . arraycopy ( oldBuffer , 0 , this . buffer , 0 , oldBuffer . length ) ; }


signature:
public class LongArray { /** * Returns the resulting buffer size in words given the number of words to add .
 * @ param number the number of words to add */
private int newSizeInWords ( int number ) { } }

implementation:
int size = this . actualSizeInWords + number ; if ( size >= this . buffer . length ) { if ( size < 32768 ) size = size * 2 ; else if ( size * 3 / 2 < size ) // overflow
size = Integer . MAX_VALUE ; else size = size * 3 / 2 ; } return size ;


signature:
public class IteratorUtil32 { /** * Turn an iterator into a bitmap
 * @ param i iterator we wish to materialize
 * @ param c where we write */
public static void materialize ( final IteratingRLW32 i , final BitmapStorage32 c ) { } }


signature:
public class IteratorUtil32 { /** * Turn an iterator into a bitmap
 * @ param i iterator we wish to materialize
 * @ param c where we write
 * @ param max maximum number of words to materialize
 * @ return how many words were actually materialized */
public static long materialize ( final IteratingRLW32 i , final BitmapStorage32 c , int max ) { } }

implementation: final int origMax = max ; while ( true ) { if ( i . getRunningLength ( ) > 0 ) { int l = i . getRunningLength ( ) ; if ( l > max ) l = max ; c . addStreamOfEmptyWords ( i . getRunningBit ( ) , l ) ; max -= l ; } long L = i . getNumberOfLiteralWords ( ) ; for ( int k = 0 ; k < L ; ++ k ) c . addWord ( i . getLiteralWordAt ( k ) ) ; if ( max > 0 ) { if ( ! i . next ( ) ) break ; } else break ; } return origMax - max ;


signature:
public class IteratorUtil32 { /** * Turn an iterator into a bitmap
 * This can be used to effectively clone a bitmap in the following
 * manner :
 * < code >
 * EWAHCompressedBitmap32 n = IteratorUtil32 . materialize ( bitmap . getIteratingRLW ( ) ) ) ;
 * n . setSizeInBitsWithinLastWord ( bitmap . sizeInBits ( ) ) ;
 * < / code >
 * @ param i iterator we wish to materialize
 * @ return materialized version of the iterator */
public static EWAHCompressedBitmap32 materialize ( final IteratingRLW32 i ) { } }

implementation: EWAHCompressedBitmap32 ewah = new EWAHCompressedBitmap32 ( ) ; materialize ( i , ewah ) ; return ewah ;


signature:
public class BufferedIterator32 { /** * Move to the next RunningLengthWord
 * @ return whether the move was possible */
@ Override public boolean next ( ) { } }

implementation: if ( ! this . iteratingBrlw . next ( ) ) { if ( ! this . masterIterator . hasNext ( ) ) { return false ; } else { this . iteratingBrlw = new IteratingBufferedRunningLengthWord32 ( this . masterIterator . next ( ) ) ; } } return true ;


signature:
public class FastAggregation32 { /** * Compute the and aggregate using a temporary uncompressed bitmap .
 * This function does not seek to match the " sizeinbits " attributes
 * of the input bitmaps .
 * @ param bitmaps the source bitmaps
 * @ param bufSize buffer size used during the computation in 64 - bit
 * words ( per input bitmap )
 * @ return the or aggregate . */
public static EWAHCompressedBitmap32 bufferedand ( final int bufSize , final EWAHCompressedBitmap32 ... bitmaps ) { } }

implementation: EWAHCompressedBitmap32 answer = new EWAHCompressedBitmap32 ( ) ; bufferedandWithContainer ( answer , bufSize , bitmaps ) ; return answer ;


signature:
public class FastAggregation32 { /** * Compute the and aggregate using a temporary uncompressed bitmap .
 * This function does not seek to match the " sizeinbits " attributes
 * of the input bitmaps .
 * @ param container where the aggregate is written
 * @ param bufSize buffer size used during the computation in 64 - bit
 * words ( per input bitmap )
 * @ param bitmaps the source bitmaps */
public static void bufferedandWithContainer ( final BitmapStorage32 container , final int bufSize , final EWAHCompressedBitmap32 ... bitmaps ) { } }

implementation: java . util . LinkedList < IteratingBufferedRunningLengthWord32 > al = new java . util . LinkedList < IteratingBufferedRunningLengthWord32 > ( ) ; for ( EWAHCompressedBitmap32 bitmap : bitmaps ) { al . add ( new IteratingBufferedRunningLengthWord32 ( bitmap ) ) ; } int [ ] hardbitmap = new int [ bufSize * bitmaps . length ] ; for ( IteratingRLW32 i : al ) if ( i . size ( ) == 0 ) { al . clear ( ) ; break ; } while ( ! al . isEmpty ( ) ) { Arrays . fill ( hardbitmap , ~ 0 ) ; int effective = Integer . MAX_VALUE ; for ( IteratingRLW32 i : al ) { int eff = IteratorAggregation32 . inplaceand ( hardbitmap , i ) ; if ( eff < effective ) effective = eff ; } for ( int k = 0 ; k < effective ; ++ k ) container . addWord ( hardbitmap [ k ] ) ; for ( IteratingRLW32 i : al ) if ( i . size ( ) == 0 ) { al . clear ( ) ; break ; } }


signature:
public class FastAggregation32 { /** * Compute the or aggregate using a temporary uncompressed bitmap .
 * @ param bitmaps the source bitmaps
 * @ param bufSize buffer size used during the computation in 64 - bit
 * words
 * @ return the or aggregate . */
public static EWAHCompressedBitmap32 bufferedor ( final int bufSize , final EWAHCompressedBitmap32 ... bitmaps ) { } }

implementation: EWAHCompressedBitmap32 answer = new EWAHCompressedBitmap32 ( ) ; bufferedorWithContainer ( answer , bufSize , bitmaps ) ; return answer ;


signature:
public class FastAggregation32 { /** * Compute the or aggregate using a temporary uncompressed bitmap .
 * @ param container where the aggregate is written
 * @ param bufSize buffer size used during the computation in 64 - bit
 * words
 * @ param bitmaps the source bitmaps */
public static void bufferedorWithContainer ( final BitmapStorage32 container , final int bufSize , final EWAHCompressedBitmap32 ... bitmaps ) { } }

implementation: int range = 0 ; EWAHCompressedBitmap32 [ ] sbitmaps = bitmaps . clone ( ) ; Arrays . sort ( sbitmaps , new Comparator < EWAHCompressedBitmap32 > ( ) { @ Override public int compare ( EWAHCompressedBitmap32 a , EWAHCompressedBitmap32 b ) { return b . sizeInBits ( ) - a . sizeInBits ( ) ; } } ) ; java . util . ArrayList < IteratingBufferedRunningLengthWord32 > al = new java . util . ArrayList < IteratingBufferedRunningLengthWord32 > ( ) ; for ( EWAHCompressedBitmap32 bitmap : sbitmaps ) { if ( bitmap . sizeInBits ( ) > range ) range = bitmap . sizeInBits ( ) ; al . add ( new IteratingBufferedRunningLengthWord32 ( bitmap ) ) ; } int [ ] hardbitmap = new int [ bufSize ] ; int maxr = al . size ( ) ; while ( maxr > 0 ) { int effective = 0 ; for ( int k = 0 ; k < maxr ; ++ k ) { if ( al . get ( k ) . size ( ) > 0 ) { int eff = IteratorAggregation32 . inplaceor ( hardbitmap , al . get ( k ) ) ; if ( eff > effective ) effective = eff ; } else maxr = k ; } for ( int k = 0 ; k < effective ; ++ k ) container . addWord ( hardbitmap [ k ] ) ; Arrays . fill ( hardbitmap , 0 ) ; } container . setSizeInBitsWithinLastWord ( range ) ;


signature:
public class FastAggregation32 { /** * Compute the xor aggregate using a temporary uncompressed bitmap .
 * @ param bitmaps the source bitmaps
 * @ param bufSize buffer size used during the computation in 64 - bit
 * words
 * @ return the xor aggregate . */
public static EWAHCompressedBitmap32 bufferedxor ( final int bufSize , final EWAHCompressedBitmap32 ... bitmaps ) { } }

implementation: EWAHCompressedBitmap32 answer = new EWAHCompressedBitmap32 ( ) ; bufferedxorWithContainer ( answer , bufSize , bitmaps ) ; return answer ;


signature:
public class FastAggregation32 { /** * Simple algorithm that computes the XOR aggregate .
 * @ param bitmaps input bitmaps
 * @ return new bitmap containing the aggregate */
public static EWAHCompressedBitmap32 xor ( final EWAHCompressedBitmap32 ... bitmaps ) { } }

implementation: PriorityQueue < EWAHCompressedBitmap32 > pq = new PriorityQueue < EWAHCompressedBitmap32 > ( bitmaps . length , new Comparator < EWAHCompressedBitmap32 > ( ) { @ Override public int compare ( EWAHCompressedBitmap32 a , EWAHCompressedBitmap32 b ) { return a . sizeInBytes ( ) - b . sizeInBytes ( ) ; } } ) ; Collections . addAll ( pq , bitmaps ) ; if ( pq . isEmpty ( ) ) return new EWAHCompressedBitmap32 ( ) ; while ( pq . size ( ) > 1 ) { EWAHCompressedBitmap32 x1 = pq . poll ( ) ; EWAHCompressedBitmap32 x2 = pq . poll ( ) ; pq . add ( x1 . xor ( x2 ) ) ; } return pq . poll ( ) ;


signature:
public class FastAggregation32 { /** * Simple algorithm that computes the OR aggregate .
 * @ param bitmaps input bitmaps
 * @ return new bitmap containing the aggregate */
public static EWAHCompressedBitmap32 or ( final Iterator < EWAHCompressedBitmap32 > bitmaps ) { } }

implementation: PriorityQueue < EWAHCompressedBitmap32 > pq = new PriorityQueue < EWAHCompressedBitmap32 > ( 32 , new Comparator < EWAHCompressedBitmap32 > ( ) { @ Override public int compare ( EWAHCompressedBitmap32 a , EWAHCompressedBitmap32 b ) { return a . sizeInBytes ( ) - b . sizeInBytes ( ) ; } } ) ; while ( bitmaps . hasNext ( ) ) pq . add ( bitmaps . next ( ) ) ; if ( pq . isEmpty ( ) ) return new EWAHCompressedBitmap32 ( ) ; while ( pq . size ( ) > 1 ) { EWAHCompressedBitmap32 x1 = pq . poll ( ) ; EWAHCompressedBitmap32 x2 = pq . poll ( ) ; pq . add ( x1 . or ( x2 ) ) ; } return pq . poll ( ) ;


signature:
public class BitCounter32 { /** * virtually add several literal words .
 * @ param buffer the buffer wrapping the literal words
 * @ param start the starting point in the array
 * @ param number the number of literal words to add */
@ Override public void addStreamOfLiteralWords ( Buffer32 buffer , int start , int number ) { } }

implementation: for ( int i = start ; i < start + number ; i ++ ) { addLiteralWord ( buffer . getWord ( i ) ) ; }


signature:
public class UpdateableBitmapFunction32 { /** * Goes through the literals .
 * @ return an iterator */
public final Iterable < EWAHPointer32 > getLiterals ( ) { } }

implementation: return new Iterable < EWAHPointer32 > ( ) { @ Override public Iterator < EWAHPointer32 > iterator ( ) { return new Iterator < EWAHPointer32 > ( ) { int k = UpdateableBitmapFunction32 . this . litwlist . nextSetBit ( 0 ) ; @ Override public boolean hasNext ( ) { return this . k >= 0 ; } @ Override public EWAHPointer32 next ( ) { EWAHPointer32 answer = UpdateableBitmapFunction32 . this . rw [ this . k ] ; this . k = UpdateableBitmapFunction32 . this . litwlist . nextSetBit ( this . k + 1 ) ; return answer ; } @ Override public void remove ( ) { throw new RuntimeException ( "N/A" ) ; } } ; } } ;


signature:
public class UpdateableBitmapFunction32 { /** * append to the list the literal words as EWAHPointer
 * @ param container where we write */
public final void fillWithLiterals ( final List < EWAHPointer32 > container ) { } }

implementation: for ( int k = this . litwlist . nextSetBit ( 0 ) ; k >= 0 ; k = this . litwlist . nextSetBit ( k + 1 ) ) { container . add ( this . rw [ k ] ) ; }


signature:
public class BufferedIterator { /** * Discard first words , iterating to the next running length word if
 * needed .
 * @ param x the number of words to be discarded */
@ Override public void discardFirstWords ( long x ) { } }

implementation: while ( x > 0 ) { if ( this . iteratingBrlw . getRunningLength ( ) > x ) { this . iteratingBrlw . discardFirstWords ( x ) ; return ; } this . iteratingBrlw . discardFirstWords ( this . iteratingBrlw . getRunningLength ( ) ) ; x -= this . iteratingBrlw . getRunningLength ( ) ; long toDiscard = x > this . iteratingBrlw . getNumberOfLiteralWords ( ) ? this . iteratingBrlw . getNumberOfLiteralWords ( ) : x ; this . iteratingBrlw . discardFirstWords ( toDiscard ) ; x -= toDiscard ; if ( ( x > 0 ) || ( this . iteratingBrlw . size ( ) == 0 ) ) { if ( ! this . next ( ) ) { break ; } } }


signature:
public class BufferedIterator { /** * Move to the next RunningLengthWord
 * @ return whether the move was possible */
@ Override public boolean next ( ) { } }

implementation: if ( ! this . iteratingBrlw . next ( ) ) { if ( ! this . masterIterator . hasNext ( ) ) { return false ; } else { this . iteratingBrlw = new IteratingBufferedRunningLengthWord ( this . masterIterator . next ( ) ) ; } } return true ;


signature:
public class IteratingBufferedRunningLengthWord { /** * Discard first words , iterating to the next running length word if
 * needed .
 * @ param x the number of words to be discarded */
@ Override public void discardFirstWords ( long x ) { } }

implementation: while ( x > 0 ) { if ( this . brlw . runningLength > x ) { this . brlw . runningLength -= x ; return ; } x -= this . brlw . runningLength ; this . brlw . runningLength = 0 ; long toDiscard = x > this . brlw . numberOfLiteralWords ? this . brlw . numberOfLiteralWords : x ; this . literalWordStartPosition += toDiscard ; this . brlw . numberOfLiteralWords -= toDiscard ; x -= toDiscard ; if ( ( x > 0 ) || ( this . brlw . size ( ) == 0 ) ) { if ( ! this . iterator . hasNext ( ) ) { break ; } this . brlw . reset ( this . iterator . next ( ) ) ; this . literalWordStartPosition = this . iterator . literalWords ( ) ; } }


signature:
public class IteratingBufferedRunningLengthWord { /** * Move to the next RunningLengthWord
 * @ return whether the move was possible */
@ Override public boolean next ( ) { } }

implementation:
if ( ! this . iterator . hasNext ( ) ) { this . brlw . numberOfLiteralWords = 0 ; this . brlw . runningLength = 0 ; return false ; } this . brlw . reset ( this . iterator . next ( ) ) ; this . literalWordStartPosition = this . iterator . literalWords ( ) ; // this . brlw . literalWordOffset
return true ;


signature:
public class IteratingBufferedRunningLengthWord { /** * Write out up to max words , returns how many were written
 * @ param container target for writes
 * @ param max maximal number of writes
 * @ return how many written */
public long discharge ( BitmapStorage container , long max ) { } }

implementation: long index = 0 ; while ( true ) { if ( index + getRunningLength ( ) > max ) { final int offset = ( int ) ( max - index ) ; container . addStreamOfEmptyWords ( getRunningBit ( ) , offset ) ; this . brlw . runningLength -= offset ; return max ; } container . addStreamOfEmptyWords ( getRunningBit ( ) , getRunningLength ( ) ) ; index += getRunningLength ( ) ; if ( getNumberOfLiteralWords ( ) + index > max ) { final int offset = ( int ) ( max - index ) ; writeLiteralWords ( offset , container ) ; this . brlw . runningLength = 0 ; this . brlw . numberOfLiteralWords -= offset ; this . literalWordStartPosition += offset ; return max ; } writeLiteralWords ( getNumberOfLiteralWords ( ) , container ) ; index += getNumberOfLiteralWords ( ) ; if ( ! next ( ) ) break ; } return index ;


signature:
public class IteratingBufferedRunningLengthWord { /** * Write out the remain words , transforming them to zeroes .
 * @ param container target for writes */
public void dischargeAsEmpty ( BitmapStorage container ) { } }

implementation: while ( size ( ) > 0 ) { container . addStreamOfEmptyWords ( false , size ( ) ) ; discardFirstWords ( size ( ) ) ; }


signature:
public class IteratingBufferedRunningLengthWord { /** * Write out the remaining words
 * @ param container target for writes */
public void discharge ( BitmapStorage container ) { } }

implementation: this . brlw . literalWordOffset = this . literalWordStartPosition - this . iterator . literalWords ( ) ; discharge ( this . brlw , this . iterator , container ) ;


signature:
public class IteratingBufferedRunningLengthWord { /** * For internal use . ( One could use the non - static discharge method
 * instead , but we expect them to be slower . )
 * @ param initialWord the initial word
 * @ param iterator the iterator
 * @ param container the container */
private static void discharge ( final BufferedRunningLengthWord initialWord , final EWAHIterator iterator , final BitmapStorage container ) { } }

implementation: BufferedRunningLengthWord runningLengthWord = initialWord ; for ( ; ; ) { final long runningLength = runningLengthWord . getRunningLength ( ) ; container . addStreamOfEmptyWords ( runningLengthWord . getRunningBit ( ) , runningLength ) ; container . addStreamOfLiteralWords ( iterator . buffer ( ) , iterator . literalWords ( ) + runningLengthWord . literalWordOffset , runningLengthWord . getNumberOfLiteralWords ( ) ) ; if ( ! iterator . hasNext ( ) ) break ; runningLengthWord = new BufferedRunningLengthWord ( iterator . next ( ) ) ; }


signature:
public class IteratorAggregation32 { /** * Aggregate the iterators using a bitmap buffer .
 * @ param al iterators to aggregate
 * @ param bufSize size of the internal buffer used by the iterator in
 * 64 - bit words
 * @ return and aggregate */
public static IteratingRLW32 bufferedand ( final int bufSize , final IteratingRLW32 ... al ) { } }

implementation: if ( al . length == 0 ) throw new IllegalArgumentException ( "Need at least one iterator" ) ; if ( al . length == 1 ) return al [ 0 ] ; final LinkedList < IteratingRLW32 > basell = new LinkedList < IteratingRLW32 > ( ) ; Collections . addAll ( basell , al ) ; return new BufferedIterator32 ( new AndIt ( basell , bufSize ) ) ;


signature:
public class IteratorAggregation32 { /** * Aggregate the iterators using a bitmap buffer .
 * @ param al iterators to aggregate
 * @ param bufSize size of the internal buffer used by the iterator in
 * 64 - bit words
 * @ return or aggregate */
public static IteratingRLW32 bufferedor ( final int bufSize , final IteratingRLW32 ... al ) { } }

implementation: if ( al . length == 0 ) throw new IllegalArgumentException ( "Need at least one iterator" ) ; if ( al . length == 1 ) return al [ 0 ] ; final LinkedList < IteratingRLW32 > basell = new LinkedList < IteratingRLW32 > ( ) ; Collections . addAll ( basell , al ) ; return new BufferedIterator32 ( new ORIt ( basell , bufSize ) ) ;


signature:
public class IteratorAggregation32 { /** * Aggregate the iterators using a bitmap buffer .
 * @ param al iterators to aggregate
 * @ param bufSize size of the internal buffer used by the iterator in
 * 64 - bit words
 * @ return xor aggregate */
public static IteratingRLW32 bufferedxor ( final int bufSize , final IteratingRLW32 ... al ) { } }

implementation: if ( al . length == 0 ) throw new IllegalArgumentException ( "Need at least one iterator" ) ; if ( al . length == 1 ) return al [ 0 ] ; final LinkedList < IteratingRLW32 > basell = new LinkedList < IteratingRLW32 > ( ) ; Collections . addAll ( basell , al ) ; return new BufferedIterator32 ( new XORIt ( basell , bufSize ) ) ;


signature:
public class IteratorAggregation32 { /** * Write out the content of the iterator , but as if it were all zeros .
 * @ param container where we write
 * @ param i the iterator */
protected static void dischargeAsEmpty ( final BitmapStorage32 container , final IteratingRLW32 i ) { } }

implementation: while ( i . size ( ) > 0 ) { container . addStreamOfEmptyWords ( false , i . size ( ) ) ; i . next ( ) ; }


signature:
public class BufferedRunningLengthWord { /** * Discard first words .
 * @ param x the x */
public void discardFirstWords ( long x ) { } }

implementation: if ( this . runningLength >= x ) { this . runningLength -= x ; return ; } x -= this . runningLength ; this . runningLength = 0 ; this . literalWordOffset += x ; this . numberOfLiteralWords -= x ;


signature:
public class BufferedRunningLengthWord { /** * Reset the values using the provided word .
 * @ param a the word */
public void reset ( final long a ) { } }

implementation: this . numberOfLiteralWords = ( int ) ( a >>> ( 1 + RunningLengthWord . RUNNING_LENGTH_BITS ) ) ; this . runningBit = ( a & 1 ) != 0 ; this . runningLength = ( int ) ( ( a >>> 1 ) & RunningLengthWord . LARGEST_RUNNING_LENGTH_COUNT ) ; this . literalWordOffset = 0 ;


signature:
public class ImmutableBitSet { /** * Get a copy of this ImmutableBitSet as a mutable BitSet .
 * @ return a copy */
public BitSet asBitSet ( ) { } }

implementation: BitSet bs = new BitSet ( this . size ( ) ) ; this . data . rewind ( ) ; this . data . get ( bs . data , 0 , bs . data . length ) ; return bs ;


signature:
public class ImmutableBitSet { /** * Compute the number of bits set to 1
 * @ return the number of bits */
public int cardinality ( ) { } }

implementation: int sum = 0 ; int length = this . data . limit ( ) ; for ( int k = 0 ; k < length ; ++ k ) sum += Long . bitCount ( this . data . get ( k ) ) ; return sum ;


signature:
public class ImmutableBitSet { /** * Check whether a bitset contains a set bit .
 * @ return true if no set bit is found */
public boolean empty ( ) { } }

implementation: int length = this . data . limit ( ) ; for ( int k = 0 ; k < length ; ++ k ) if ( this . data . get ( k ) != 0 ) return false ; return true ;


signature:
public class ImmutableBitSet { /** * Iterate over the set bits
 * @ return an iterator */
public IntIterator intIterator ( ) { } }

implementation: return new IntIterator ( ) { @ Override public boolean hasNext ( ) { return this . i >= 0 ; } @ Override public int next ( ) { this . j = this . i ; this . i = ImmutableBitSet . this . nextSetBit ( this . i + 1 ) ; return this . j ; } private int i = ImmutableBitSet . this . nextSetBit ( 0 ) ; private int j ; } ;


signature:
public class ImmutableBitSet { /** * Checks whether two bitsets intersect .
 * @ param bs other bitset
 * @ return true if they have a non - empty intersection ( result of AND ) */
public boolean intersects ( BitSet bs ) { } }

implementation: for ( int k = 0 ; k < Math . min ( this . data . limit ( ) , bs . data . length ) ; ++ k ) { if ( ( this . data . get ( k ) & bs . data [ k ] ) != 0 ) return true ; } return false ;


signature:
public class ImmutableBitSet { /** * Usage : for ( int i = bs . nextSetBit ( 0 ) ; i & gt ; = 0 ; i = bs . nextSetBit ( i + 1 ) ) {
 * operate on index i here }
 * @ param i current set bit
 * @ return next set bit or - 1 */
public int nextSetBit ( final int i ) { } }

implementation: int x = i / 64 ; if ( x >= this . data . limit ( ) ) return - 1 ; long w = this . data . get ( x ) ; w >>>= ( i % 64 ) ; if ( w != 0 ) { return i + Long . numberOfTrailingZeros ( w ) ; } ++ x ; for ( ; x < this . data . limit ( ) ; ++ x ) { if ( this . data . get ( x ) != 0 ) { return x * 64 + Long . numberOfTrailingZeros ( this . data . get ( x ) ) ; } } return - 1 ;


signature:
public class ImmutableBitSet { /** * Iterate over the unset bits
 * @ return an iterator */
public IntIterator unsetIntIterator ( ) { } }

implementation: return new IntIterator ( ) { @ Override public boolean hasNext ( ) { return this . i >= 0 ; } @ Override public int next ( ) { this . j = this . i ; this . i = ImmutableBitSet . this . nextUnsetBit ( this . i + 1 ) ; return this . j ; } private int i = ImmutableBitSet . this . nextUnsetBit ( 0 ) ; private int j ; } ;


signature:
public class IteratingBufferedRunningLengthWord32 { /** * Discard first words , iterating to the next running length word if
 * needed .
 * @ param x the x */
@ Override public void discardFirstWords ( int x ) { } }

implementation: while ( x > 0 ) { if ( this . brlw . RunningLength > x ) { this . brlw . RunningLength -= x ; return ; } x -= this . brlw . RunningLength ; this . brlw . RunningLength = 0 ; int toDiscard = x > this . brlw . NumberOfLiteralWords ? this . brlw . NumberOfLiteralWords : x ; this . literalWordStartPosition += toDiscard ; this . brlw . NumberOfLiteralWords -= toDiscard ; x -= toDiscard ; if ( ( x > 0 ) || ( this . brlw . size ( ) == 0 ) ) { if ( ! this . iterator . hasNext ( ) ) { break ; } this . brlw . reset ( this . iterator . next ( ) ) ; this . literalWordStartPosition = this . iterator . literalWords ( ) ; } }


signature:
public class IteratingBufferedRunningLengthWord32 { /** * Write out up to max words , returns how many were written
 * @ param container target for writes
 * @ param max maximal number of writes
 * @ return how many written */
public int discharge ( BitmapStorage32 container , int max ) { } }

implementation: int index = 0 ; while ( true ) { if ( index + getRunningLength ( ) > max ) { final int offset = max - index ; container . addStreamOfEmptyWords ( getRunningBit ( ) , offset ) ; this . brlw . RunningLength -= offset ; return max ; } container . addStreamOfEmptyWords ( getRunningBit ( ) , getRunningLength ( ) ) ; index += getRunningLength ( ) ; if ( getNumberOfLiteralWords ( ) + index > max ) { final int offset = max - index ; writeLiteralWords ( offset , container ) ; this . brlw . RunningLength = 0 ; this . brlw . NumberOfLiteralWords -= offset ; this . literalWordStartPosition += offset ; return max ; } writeLiteralWords ( getNumberOfLiteralWords ( ) , container ) ; index += getNumberOfLiteralWords ( ) ; if ( ! next ( ) ) break ; } return index ;