本文整理汇总了Java中android.util.SparseIntArray.valueAt方法的典型用法代码示例。如果您正苦于以下问题:Java SparseIntArray.valueAt方法的具体用法?Java SparseIntArray.valueAt怎么用?Java SparseIntArray.valueAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.SparseIntArray
的用法示例。
在下文中一共展示了SparseIntArray.valueAt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initBuckets
import android.util.SparseIntArray; //导入方法依赖的package包/类
/**
* Initialize the list of buckets. Get the bucket sizes (and bucket lengths) from the bucket
* sizes provider
* @param inUseCounts map of current buckets and their in use counts
*/
private synchronized void initBuckets(SparseIntArray inUseCounts) {
Preconditions.checkNotNull(inUseCounts);
// clear out all the buckets
mBuckets.clear();
// create the new buckets
final SparseIntArray bucketSizes = mPoolParams.bucketSizes;
if (bucketSizes != null) {
for (int i = 0; i < bucketSizes.size(); ++i) {
final int bucketSize = bucketSizes.keyAt(i);
final int maxLength = bucketSizes.valueAt(i);
int bucketInUseCount = inUseCounts.get(bucketSize, 0);
mBuckets.put(
bucketSize,
new Bucket<V>(
getSizeInBytes(bucketSize),
maxLength,
bucketInUseCount));
}
mAllowNewBuckets = false;
} else {
mAllowNewBuckets = true;
}
}
示例2: getMaxAnswersId
import android.util.SparseIntArray; //导入方法依赖的package包/类
private int getMaxAnswersId() {
int max = 0;
int id = 0;
SparseIntArray answers = new SparseIntArray();
for (QA qa : socTest.getQa()) {
int answer = qa.getAnswer();
answers.put(answer, answers.get(answer, 0) + 1);
}
for (int i = 0; i < answers.size(); i++) {
if (max < answers.valueAt(i)) {
max = answers.valueAt(i);
id = answers.keyAt(i);
}
}
return id;
}
示例3: binarySearch
import android.util.SparseIntArray; //导入方法依赖的package包/类
/**
* Binary search for the closest value that's smaller than or equal to {@code value}, and
* return the corresponding key.
*/
private static int binarySearch(SparseIntArray array, int value) {
final int size = array.size();
int lo = 0;
int hi = size - 1;
while (lo <= hi) {
final int mid = (lo + hi) >>> 1;
final int midVal = array.valueAt(mid);
if (midVal < value) {
lo = mid + 1;
} else if (midVal > value) {
hi = mid - 1;
} else {
return array.keyAt(mid); // value found
}
}
// Value not found. Return the last item before our search range, which is the closest
// value smaller than the value we are looking for.
return array.keyAt(lo - 1);
}
示例4: getTicketTrains
import android.util.SparseIntArray; //导入方法依赖的package包/类
private List<Map<String, String>> getTicketTrains() {
List<Map<String, String>> lstTicketTrains = new ArrayList<Map<String, String>>();
List<Integer> lstTemp = new ArrayList<Integer>();
TrainHelper tHelper = new TrainHelper();
SparseIntArray saTrainSpeeds = tHelper.getTrainSpeeds();
for (int i = 0; i < mLstInfos.size(); i++) {
QueryLeftNewDTOInfo qldInfo = mLstInfos.get(i)
.getQueryLeftNewDTO();
if (!lstTemp.contains(qldInfo.getSpeed_index()) || qldInfo.isHasPreferentialPrice()){
if (!qldInfo.isHasPreferentialPrice()){
lstTemp.add(qldInfo.getSpeed_index());
}
Map<String, String> map = new HashMap<String, String>();
map.put(TT.TRAIN_NO, qldInfo.getTrain_no());
String strName = "";
for(int j=0; j<saTrainSpeeds.size(); j++){
if (saTrainSpeeds.valueAt(j) == qldInfo.getSpeed_index()){
strName = tHelper.getTrainNames().get(saTrainSpeeds.keyAt(j));
break;
}
}
map.put(TT.TRAIN_CLASS_NAME, qldInfo.isHasPreferentialPrice()?
("<font color='#ff8c00'>[折]</font>"+qldInfo.getStation_train_code()):strName);
map.put(TT.FROM_STATION_NO, qldInfo.getFrom_station_no());
map.put(TT.TO_STATION_NO, qldInfo.getTo_station_no());
map.put(TT.SEAT_TYPES, qldInfo.getSeat_types());
lstTicketTrains.add(map);
}
}
return lstTicketTrains;
}
示例5: dropViews
import android.util.SparseIntArray; //导入方法依赖的package包/类
void dropViews(SparseIntArray viewsToDrop) {
for (int i = 0, count = viewsToDrop.size(); i < count; i++) {
int viewToDrop = viewsToDrop.keyAt(i);
View view = null;
if (viewToDrop > 0) {
try {
view = resolveView(viewToDrop);
dropView(view);
} catch (Exception e) {
// the view is already dropped, nothing we can do
}
} else {
// Root views are noted with a negative tag from StateBuilder.
removeRootView(-viewToDrop);
}
int parentTag = viewsToDrop.valueAt(i);
// this only happens for clipped, non-root views - clipped because there is no parent, and
// not a root view (because we explicitly pass -1 for root views).
if (parentTag > 0 && view != null && view.getParent() == null) {
// this can only happen if the parent exists (if the parent were removed first, it'd also
// remove the child, so trying to explicitly remove the child afterwards would crash at
// the resolveView call above) - we also explicitly check for a null parent, implying that
// we are either clipped (or that we already removed the child from its parent, in which
// case this will essentially be a no-op).
View parent = resolveView(parentTag);
if (parent instanceof FlatViewGroup) {
((FlatViewGroup) parent).onViewDropped(view);
}
}
}
}