当前位置: 首页>>代码示例>>Java>>正文


Java SparseIntArray.size方法代码示例

本文整理汇总了Java中android.util.SparseIntArray.size方法的典型用法代码示例。如果您正苦于以下问题:Java SparseIntArray.size方法的具体用法?Java SparseIntArray.size怎么用?Java SparseIntArray.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.util.SparseIntArray的用法示例。


在下文中一共展示了SparseIntArray.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:BasePool.java

示例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;
}
 
开发者ID:Komdosh,项目名称:SocEltech,代码行数:20,代码来源:TestViewActivity.java

示例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);
}
 
开发者ID:Trumeet,项目名称:SetupWizardLibCompat,代码行数:26,代码来源:ItemGroup.java

示例4: adjustPosition

import android.util.SparseIntArray; //导入方法依赖的package包/类
/**
 * internal method to handle the selections if items are added / removed
 *
 * @param positions     the positions map which should be adjusted
 * @param startPosition the global index of the first element modified
 * @param endPosition   the global index up to which the modification changed the indices (should be MAX_INT if we check til the end)
 * @param adjustBy      the value by which the data was shifted
 * @return the adjusted map
 */
public static SparseIntArray adjustPosition(SparseIntArray positions, int startPosition, int endPosition, int adjustBy) {
    SparseIntArray newPositions = new SparseIntArray();

    for (int i = 0, size = positions.size(); i < size; i++) {
        int position = positions.keyAt(i);

        //if our current position is not within the bounds to check for we can add it
        if (position < startPosition || position > endPosition) {
            newPositions.put(position, positions.valueAt(i));
        } else if (adjustBy > 0) {
            //if we added items and we are within the bounds we can simply add the adjustBy to our entry
            newPositions.put(position + adjustBy, positions.valueAt(i));
        } else if (adjustBy < 0) {
            //if we removed items and we are within the bounds we have to check if the item was removed
            //adjustBy is negative in this case
            if (position > startPosition + adjustBy && position <= startPosition) {
                ;//we are within the removed items range we don't add this item anymore
            } else {
                //otherwise we adjust our position
                newPositions.put(position + adjustBy, positions.valueAt(i));
            }
        }
    }

    return newPositions;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:AdapterUtil.java

示例5: GenericByteArrayPool

import android.util.SparseIntArray; //导入方法依赖的package包/类
/**
 * Creates a new instance of the GenericByteArrayPool class
 * @param memoryTrimmableRegistry the memory manager to register with
 * @param poolParams provider for pool parameters
 * @param poolStatsTracker
 */
public GenericByteArrayPool(
    MemoryTrimmableRegistry memoryTrimmableRegistry,
    PoolParams poolParams,
    PoolStatsTracker poolStatsTracker) {
  super(memoryTrimmableRegistry, poolParams, poolStatsTracker);
  final SparseIntArray bucketSizes = poolParams.bucketSizes;
  mBucketSizes = new int[bucketSizes.size()];
  for (int i = 0; i < bucketSizes.size(); ++i) {
    mBucketSizes[i] = bucketSizes.keyAt(i);
  }
  initialize();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:GenericByteArrayPool.java

示例6: NativeMemoryChunkPool

import android.util.SparseIntArray; //导入方法依赖的package包/类
/**
 * Creates a new instance of the NativeMemoryChunkPool class
 * @param memoryTrimmableRegistry the memory manager to register with
 * @param poolParams provider for pool parameters
 * @param nativeMemoryChunkPoolStatsTracker
 */
public NativeMemoryChunkPool(
    MemoryTrimmableRegistry memoryTrimmableRegistry,
    PoolParams poolParams,
    PoolStatsTracker nativeMemoryChunkPoolStatsTracker) {
  super(memoryTrimmableRegistry, poolParams, nativeMemoryChunkPoolStatsTracker);
  SparseIntArray bucketSizes = poolParams.bucketSizes;
  mBucketSizes = new int[bucketSizes.size()];
  for (int i = 0; i < mBucketSizes.length; ++i) {
    mBucketSizes[i] = bucketSizes.keyAt(i);
  }
  initialize();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:NativeMemoryChunkPool.java

示例7: handleView

import android.util.SparseIntArray; //导入方法依赖的package包/类
/**
 * Handle view to support used by app.
 *
 * @param v View resource from skin package.
 */
public void handleView(Context context, View v) {
    resetID();
    //Id map: Key as skin id and Value as local id.
    SparseIntArray array = new SparseIntArray();
    buildIdRules(context, v, array);
    int size = array.size();
    // Map ids to which app can recognize locally.
    for (int i = 0; i < size; i++) {
        //Map id defined in skin package into real id in app.
        v.findViewById(array.keyAt(i)).setId(array.valueAt(i));
    }
}
 
开发者ID:Zeal27,项目名称:SkinFramework,代码行数:18,代码来源:SkinResource.java

示例8: 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;
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:32,代码来源:TrainSchListAty.java

示例9: sparseIntArrayAsList

import android.util.SparseIntArray; //导入方法依赖的package包/类
/**
 * Same as {@link MainActivity#asList(SparseArray)} but for SparseIntArray
 *
 * @param sparseIntArray Array to be converted
 * @return returns resulting ArrayList
 */

private static List<Integer> sparseIntArrayAsList(SparseIntArray sparseIntArray)
{
    if (sparseIntArray == null)
    {
        return null;
    }
    List<Integer> arrayList = new ArrayList<>(sparseIntArray.size());
    for (int i = 0; i < sparseIntArray.size(); i++)
        arrayList.add(sparseIntArray.valueAt(i));
    return arrayList;
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:19,代码来源:MainActivity.java

示例10: isRunning

import android.util.SparseIntArray; //导入方法依赖的package包/类
public static boolean isRunning(SparseIntArray status) {
    if (status == null) {
        return false;
    }
    int size = status.size();
    for (int i = 0; i < size; ++i) {
        int processState = status.keyAt(i);
        if (isProcess(processState)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:14,代码来源:BreventResponse.java

示例11: isService

import android.util.SparseIntArray; //导入方法依赖的package包/类
public static boolean isService(@NonNull SparseIntArray status) {
    int size = status.size();
    for (int i = 0; i < size; ++i) {
        int processState = status.keyAt(i);
        if (isService(processState)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:11,代码来源:BreventResponse.java

示例12: isSafe

import android.util.SparseIntArray; //导入方法依赖的package包/类
public static boolean isSafe(@NonNull SparseIntArray status) {
    int size = status.size();
    for (int i = 0; i < size; ++i) {
        int processState = status.keyAt(i);
        if (BreventResponse.isProcess(processState) && !HideApiOverride.isSafe(processState)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:11,代码来源:BreventResponse.java

示例13: isForegroundService

import android.util.SparseIntArray; //导入方法依赖的package包/类
public static boolean isForegroundService(@NonNull SparseIntArray status) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int size = status.size();
        for (int i = 0; i < size; ++i) {
            int processState = status.keyAt(i);
            if (HideApiOverride.isForegroundService(processState)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:13,代码来源:BreventResponse.java

示例14: writeSparseIntArray

import android.util.SparseIntArray; //导入方法依赖的package包/类
private static void writeSparseIntArray(Parcel dest, @Nullable SparseIntArray array) {
    if (array == null) {
        dest.writeInt(-1);
    } else {
        int size = array.size();
        dest.writeInt(size);
        for (int i = 0; i < size; ++i) {
            dest.writeInt(array.keyAt(i));
            dest.writeInt(array.valueAt(i));
        }
    }
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:13,代码来源:ParcelUtils.java

示例15: 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);
      }
    }
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:33,代码来源:FlatNativeViewHierarchyManager.java


注:本文中的android.util.SparseIntArray.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。