public bool GetItemIndexAndPosAtGivenPos(float pos, ref int index, ref float itemPos) { Update(true); index = 0; itemPos = 0f; int count = mItemSizeGroupList.Count; if (count == 0) { return(true); } ItemSizeGroup hitGroup = null; int low = 0; int high = count - 1; if (mItemDefaultSize == 0f) { if (mMaxNotEmptyGroupIndex < 0) { mMaxNotEmptyGroupIndex = 0; } high = mMaxNotEmptyGroupIndex; } while (low <= high) { int mid = (low + high) / 2; ItemSizeGroup tGroup = mItemSizeGroupList[mid]; if (tGroup.mGroupStartPos <= pos && tGroup.mGroupEndPos >= pos) { hitGroup = tGroup; break; } else if (pos > tGroup.mGroupEndPos) { low = mid + 1; } else { high = mid - 1; } } int hitIndex = -1; if (hitGroup != null) { hitIndex = hitGroup.GetItemIndexByPos(pos - hitGroup.mGroupStartPos); } else { return(false); } if (hitIndex < 0) { return(false); } index = hitIndex + hitGroup.mGroupIndex * mItemMaxCountPerGroup; itemPos = hitGroup.GetItemStartPos(hitIndex); return(true); }
public bool GetItemIndexAndPosAtGivenPos(float pos, ref int index, ref float itemPos) { this.Update(true); index = 0; itemPos = 0.0f; int count = this.mItemSizeGroupList.Count; if (count == 0) { return(true); } ItemSizeGroup itemSizeGroup = (ItemSizeGroup)null; int num1 = 0; int num2 = count - 1; if ((double)this.mItemDefaultSize == 0.0) { if (this.mMaxNotEmptyGroupIndex < 0) { this.mMaxNotEmptyGroupIndex = 0; } num2 = this.mMaxNotEmptyGroupIndex; } while (num1 <= num2) { int index1 = (num1 + num2) / 2; ItemSizeGroup mItemSizeGroup = this.mItemSizeGroupList[index1]; if ((double)mItemSizeGroup.mGroupStartPos <= (double)pos && (double)mItemSizeGroup.mGroupEndPos >= (double)pos) { itemSizeGroup = mItemSizeGroup; break; } if ((double)pos > (double)mItemSizeGroup.mGroupEndPos) { num1 = index1 + 1; } else { num2 = index1 - 1; } } if (itemSizeGroup == null) { return(false); } int itemIndexByPos = itemSizeGroup.GetItemIndexByPos(pos - itemSizeGroup.mGroupStartPos); if (itemIndexByPos < 0) { return(false); } index = itemIndexByPos + itemSizeGroup.mGroupIndex * 100; itemPos = itemSizeGroup.GetItemStartPos(itemIndexByPos); return(true); }
public void GetItemIndexAndPosAtGivenPos(float pos, ref int index, ref float itemPos) { this.Update(true); index = 0; itemPos = 0f; int count = this.mItemSizeGroupList.Count; if (count == 0) { return; } ItemSizeGroup hitGroup = null; int low = 0; int high = count - 1; while (low <= high) { int mid = (low + high) / 2; ItemSizeGroup tGroup = this.mItemSizeGroupList[mid]; if (tGroup.mGroupStartPos <= pos && tGroup.mGroupEndPos >= pos) { hitGroup = tGroup; break; } else if (pos > tGroup.mGroupEndPos) { low = mid + 1; } else { high = mid - 1; } } int hitIndex = -1; if (hitGroup != null) { hitIndex = hitGroup.GetItemIndexByPos(pos - hitGroup.mGroupStartPos); } else { return; } if (hitIndex < 0) { return; } index = hitIndex + hitGroup.mGroupIndex * mItemMaxCountPerGroup; itemPos = hitGroup.GetItemStartPos(hitIndex); }