List of usage examples for java.util BitSet set
public void set(int fromIndex, int toIndex, boolean value)
From source file:org.apache.carbondata.core.scan.filter.FilterUtil.java
/** * This method will create default bitset group. Applicable for restructure scenarios. * * @param pageCount/*from ww w.j av a 2 s . c om*/ * @param totalRowCount * @param defaultValue * @return */ public static BitSetGroup createBitSetGroupWithDefaultValue(int pageCount, int totalRowCount, boolean defaultValue) { BitSetGroup bitSetGroup = new BitSetGroup(pageCount); int numberOfRows = CarbonV3DataFormatConstants.NUMBER_OF_ROWS_PER_BLOCKLET_COLUMN_PAGE_DEFAULT; int pagesTobeFullFilled = totalRowCount / numberOfRows; int rowCountForLastPage = totalRowCount % numberOfRows; for (int i = 0; i < pagesTobeFullFilled; i++) { BitSet bitSet = new BitSet(numberOfRows); bitSet.set(0, numberOfRows, defaultValue); bitSetGroup.setBitSet(bitSet, i); } // create and fill bitset for the last page if any records are left if (rowCountForLastPage > 0) { BitSet bitSet = new BitSet(rowCountForLastPage); bitSet.set(0, rowCountForLastPage, defaultValue); bitSetGroup.setBitSet(bitSet, pagesTobeFullFilled); } return bitSetGroup; }
From source file:com.alibaba.android.layoutmanager.layoutmanager.StaggeredGridLayoutHelper.java
/** * Checks for gaps if we've reached to the top of the list. * <p/>//from w w w .j a v a2s. c o m * Intermediate gaps created by full span items are tracked via mLaidOutInvalidFullSpan field. */ private View hasGapsToFix(VirtualLayoutManager layoutManager, final int position, final int alignLine) { View view = layoutManager.findViewByPosition(position); if (view == null) { return null; } BitSet mSpansToCheck = new BitSet(mNumLanes); mSpansToCheck.set(0, mNumLanes, true); for (Span span : mSpans) { if (span.mViews.size() != 0 && checkSpanForGap(span, layoutManager, alignLine)) { return layoutManager.getReverseLayout() ? span.mViews.get(span.mViews.size() - 1) : span.mViews.get(0); } } // everything looks good return null; }
From source file:android.support.v7.widget.StaggeredGridLayoutManager2.java
/** * Checks for gaps if we've reached to the top of the list. * <p>//from www . j a v a 2 s . co m * Intermediate gaps created by full span items are tracked via mLaidOutInvalidFullSpan field. */ View hasGapsToFix() { int startChildIndex = 0; int endChildIndex = getChildCount() - 1; BitSet mSpansToCheck = new BitSet(mSpanCount); mSpansToCheck.set(0, mSpanCount, true); final int firstChildIndex, childLimit; final int preferredSpanDir = mOrientation == VERTICAL && isLayoutRTL() ? 1 : -1; if (mShouldReverseLayout) { firstChildIndex = endChildIndex - 1; childLimit = startChildIndex - 1; } else { firstChildIndex = startChildIndex; childLimit = endChildIndex; } final int nextChildDiff = firstChildIndex < childLimit ? 1 : -1; for (int i = firstChildIndex; i != childLimit; i += nextChildDiff) { View child = getChildAt(i); LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (mSpansToCheck.get(lp.mSpan.mIndex)) { if (checkSpanForGap(lp.mSpan)) { return child; } mSpansToCheck.clear(lp.mSpan.mIndex); } if (lp.mFullSpan) { continue; // quick reject } if (i + nextChildDiff != childLimit) { View nextChild = getChildAt(i + nextChildDiff); boolean compareSpans = false; if (mShouldReverseLayout) { // ensure child's end is below nextChild's end int myEnd = mPrimaryOrientation.getDecoratedEnd(child); int nextEnd = mPrimaryOrientation.getDecoratedEnd(nextChild); if (myEnd < nextEnd) { return child;//i should have a better position } else if (myEnd == nextEnd) { compareSpans = true; } } else { int myStart = mPrimaryOrientation.getDecoratedStart(child); int nextStart = mPrimaryOrientation.getDecoratedStart(nextChild); if (myStart > nextStart) { return child;//i should have a better position } else if (myStart == nextStart) { compareSpans = true; } } if (compareSpans) { // equal, check span indices. LayoutParams nextLp = (LayoutParams) nextChild.getLayoutParams(); if (lp.mSpan.mIndex - nextLp.mSpan.mIndex < 0 != preferredSpanDir < 0) { return child; } } } } // everything looks good return null; }
From source file:android.support.v7.widget.StaggeredGridLayoutManager.java
/** * Checks for gaps if we've reached to the top of the list. * <p>/* ww w . j ava 2 s .c o m*/ * Intermediate gaps created by full span items are tracked via mLaidOutInvalidFullSpan field. */ View hasGapsToFix() { int startChildIndex = 0; int endChildIndex = getChildCount() - 1; BitSet mSpansToCheck = new BitSet(mSpanCount); mSpansToCheck.set(0, mSpanCount, true); final int firstChildIndex, childLimit; final int preferredSpanDir = mOrientation == VERTICAL && isLayoutRTL() ? 1 : -1; if (mShouldReverseLayout) { firstChildIndex = endChildIndex; childLimit = startChildIndex - 1; } else { firstChildIndex = startChildIndex; childLimit = endChildIndex + 1; } final int nextChildDiff = firstChildIndex < childLimit ? 1 : -1; for (int i = firstChildIndex; i != childLimit; i += nextChildDiff) { View child = getChildAt(i); LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (mSpansToCheck.get(lp.mSpan.mIndex)) { if (checkSpanForGap(lp.mSpan)) { return child; } mSpansToCheck.clear(lp.mSpan.mIndex); } if (lp.mFullSpan) { continue; // quick reject } if (i + nextChildDiff != childLimit) { View nextChild = getChildAt(i + nextChildDiff); boolean compareSpans = false; if (mShouldReverseLayout) { // ensure child's end is below nextChild's end int myEnd = mPrimaryOrientation.getDecoratedEnd(child); int nextEnd = mPrimaryOrientation.getDecoratedEnd(nextChild); if (myEnd < nextEnd) { return child;//i should have a better position } else if (myEnd == nextEnd) { compareSpans = true; } } else { int myStart = mPrimaryOrientation.getDecoratedStart(child); int nextStart = mPrimaryOrientation.getDecoratedStart(nextChild); if (myStart > nextStart) { return child;//i should have a better position } else if (myStart == nextStart) { compareSpans = true; } } if (compareSpans) { // equal, check span indices. LayoutParams nextLp = (LayoutParams) nextChild.getLayoutParams(); if (lp.mSpan.mIndex - nextLp.mSpan.mIndex < 0 != preferredSpanDir < 0) { return child; } } } } // everything looks good return null; }