Refine search
@Override public void onItemRangeRemoved(int positionStart, int itemCount) { if (itemCount == 0) { // no-op return; } List<ModelState> modelsToRemove = currentStateList.subList(positionStart, positionStart + itemCount); for (ModelState model : modelsToRemove) { currentStateMap.remove(model.id); } modelsToRemove.clear(); // Update positions of affected items int size = currentStateList.size(); for (int i = positionStart; i < size; i++) { currentStateList.get(i).position -= itemCount; } }
public synchronized List<QueryEntry> getQueries() { // return a copy of the map so we don't have to // worry about external synchronization ArrayList<QueryEntry> list = new ArrayList<QueryEntry>(); list.addAll(map.values()); // only return the newest 100 entries Collections.sort(list, QUERY_ENTRY_COMPARATOR); return list.subList(0, Math.min(list.size(), maxQueryEntries)); }
/** * Copies a path */ private static void duplicatePath(int lastPathIndex, State fromState, State toState, ArrayList<ArrayList<State>> paths) { ArrayList<State> lastPath = paths.get(lastPathIndex); // copy the last path to a new one, from start to current state int fromIndex = lastPath.indexOf(fromState); int toIndex = lastPath.indexOf(toState); if (toIndex == -1) { toIndex = lastPath.size() - 1; } ArrayList<State> newPath = new ArrayList<State>(lastPath.subList( fromIndex, toIndex)); paths.add(newPath); }
if (!matchLimited || matchList.size() < limit - 1) { final String match = input.subSequence(index, m.start()).toString(); matchList.add(match); index = m.end(); else if (matchList.size() == limit - 1) { // last one final String match = input.subSequence(index, input.length()).toString(); matchList.add(match); index = m.end(); if (!matchLimited || matchList.size() < limit) { matchList.add(input.subSequence(index, input.length()).toString()); return matchList.subList(0, resultSize).toArray(result);
/** * For a given Enum type, creates an immutable map from each of the Enum's values to a * corresponding LockGraphNode, with the {@code allowedPriorLocks} and {@code * disallowedPriorLocks} prepopulated with nodes according to the natural ordering of the * associated Enum values. */ @VisibleForTesting static <E extends Enum<E>> Map<E, LockGraphNode> createNodes(Class<E> clazz) { EnumMap<E, LockGraphNode> map = Maps.newEnumMap(clazz); E[] keys = clazz.getEnumConstants(); final int numKeys = keys.length; ArrayList<LockGraphNode> nodes = Lists.newArrayListWithCapacity(numKeys); // Create a LockGraphNode for each enum value. for (E key : keys) { LockGraphNode node = new LockGraphNode(getLockName(key)); nodes.add(node); map.put(key, node); } // Pre-populate all allowedPriorLocks with nodes of smaller ordinal. for (int i = 1; i < numKeys; i++) { nodes.get(i).checkAcquiredLocks(Policies.THROW, nodes.subList(0, i)); } // Pre-populate all disallowedPriorLocks with nodes of larger ordinal. for (int i = 0; i < numKeys - 1; i++) { nodes.get(i).checkAcquiredLocks(Policies.DISABLED, nodes.subList(i + 1, numKeys)); } return Collections.unmodifiableMap(map); }
@Override public void add(int position, @NonNull Group group) { super.add(position, group); children.add(position, group); final int notifyPosition = getHeaderItemCount() + getItemCount(children.subList(0, position)); notifyItemRangeInserted(notifyPosition, group.getItemCount()); refreshEmptyState(); }
if (!matchLimited || matchList.size() < limit - 1) { String match = input.subSequence(index, m.start()).toString(); matchList.add(match); index = m.end(); } else if (matchList.size() == limit - 1) { // last one String match = input.subSequence(index, input.length()).toString(); matchList.add(match); index = m.end(); if (!matchLimited || matchList.size() < limit) matchList.add(input.subSequence(index, input.length()).toString()); int resultSize = matchList.size(); if (limit == 0) while (resultSize > 0 && matchList.get(resultSize-1).equals("")) resultSize--; String[] result = new String[resultSize]; return matchList.subList(0, resultSize).toArray(result);
public static void exportDiskStore(ArrayList<String> args, String outputDir) { File out = outputDir == null ? new File(".") : new File(outputDir); if (!out.exists()) { out.mkdirs(); } String dsName = args.get(0); File[] dirs = argsToFile(args.subList(1, args.size())); try { DiskStoreImpl.exportOfflineSnapshot(dsName, dirs, out); } catch (Exception ex) { throw new GemFireIOException(" disk-store=" + dsName + ": " + ex, ex); } }
/** * For a given Enum type, creates an immutable map from each of the Enum's values to a * corresponding LockGraphNode, with the {@code allowedPriorLocks} and {@code * disallowedPriorLocks} prepopulated with nodes according to the natural ordering of the * associated Enum values. */ @VisibleForTesting static <E extends Enum<E>> Map<E, LockGraphNode> createNodes(Class<E> clazz) { EnumMap<E, LockGraphNode> map = Maps.newEnumMap(clazz); E[] keys = clazz.getEnumConstants(); final int numKeys = keys.length; ArrayList<LockGraphNode> nodes = Lists.newArrayListWithCapacity(numKeys); // Create a LockGraphNode for each enum value. for (E key : keys) { LockGraphNode node = new LockGraphNode(getLockName(key)); nodes.add(node); map.put(key, node); } // Pre-populate all allowedPriorLocks with nodes of smaller ordinal. for (int i = 1; i < numKeys; i++) { nodes.get(i).checkAcquiredLocks(Policies.THROW, nodes.subList(0, i)); } // Pre-populate all disallowedPriorLocks with nodes of larger ordinal. for (int i = 0; i < numKeys - 1; i++) { nodes.get(i).checkAcquiredLocks(Policies.DISABLED, nodes.subList(i + 1, numKeys)); } return Collections.unmodifiableMap(map); }
public static List<Song> searchSongs(Context context, String searchString, int limit) { ArrayList<Song> result = getSongsForCursor(makeSongCursor(context, "title LIKE ?", new String[]{searchString + "%"})); if (result.size() < limit) { result.addAll(getSongsForCursor(makeSongCursor(context, "title LIKE ?", new String[]{"%_" + searchString + "%"}))); } return result.size() < limit ? result : result.subList(0, limit); }
/** * ExpressionTypes. * */ public static enum ExpressionTypes { FIELD, JEXL }; public static final String LLAP_OUTPUT_FORMAT_KEY = "Llap";
public static void showDiskStoreMetadata(ArrayList<String> args) { String dsName = args.get(0); File[] dirs = argsToFile(args.subList(1, args.size())); try { DiskStoreImpl.dumpMetadata(dsName, dirs, showBuckets); } catch (Exception ex) { throw new GemFireIOException(" disk-store=" + dsName + ": " + ex, ex); } }
void addToView(){ int index; if(this.device instanceof AP){ index = i; if(i>0 && getComparatorForAP()!=null){ index = findIndex(tiles.subList(0, i), this, getComparatorForAP()); } i++; }else{ index = tiles.size(); if(tiles.size() - i > 0 && getComparatorForST()!=null){ index = findIndex(tiles.subList(i, tiles.size()), this, getComparatorForST()) + i; } } tiles.add(index, this); adapter.insert(this, index); onCountsChanged(); } static int findIndex(List<Tile> list, Tile tile, Comparator<Tile> comp){
/** * For a given Enum type, creates an immutable map from each of the Enum's values to a * corresponding LockGraphNode, with the {@code allowedPriorLocks} and {@code * disallowedPriorLocks} prepopulated with nodes according to the natural ordering of the * associated Enum values. */ @VisibleForTesting static <E extends Enum<E>> Map<E, LockGraphNode> createNodes(Class<E> clazz) { EnumMap<E, LockGraphNode> map = Maps.newEnumMap(clazz); E[] keys = clazz.getEnumConstants(); final int numKeys = keys.length; ArrayList<LockGraphNode> nodes = Lists.newArrayListWithCapacity(numKeys); // Create a LockGraphNode for each enum value. for (E key : keys) { LockGraphNode node = new LockGraphNode(getLockName(key)); nodes.add(node); map.put(key, node); } // Pre-populate all allowedPriorLocks with nodes of smaller ordinal. for (int i = 1; i < numKeys; i++) { nodes.get(i).checkAcquiredLocks(Policies.THROW, nodes.subList(0, i)); } // Pre-populate all disallowedPriorLocks with nodes of larger ordinal. for (int i = 0; i < numKeys - 1; i++) { nodes.get(i).checkAcquiredLocks(Policies.DISABLED, nodes.subList(i + 1, numKeys)); } return Collections.unmodifiableMap(map); }
public synchronized List<QueryEntry> getQueries() { // return a copy of the map so we don't have to // worry about external synchronization ArrayList<QueryEntry> list = new ArrayList<>(map.values()); // only return the newest 100 entries Collections.sort(list, QUERY_ENTRY_COMPARATOR); return list.subList(0, Math.min(list.size(), maxQueryEntries)); }
ArrayList<PathParser.PathDataNode> transformTo = PathNodeUtils.transform(to, 0, true); int fromSize = transformFrom.size(); int toSize = transformTo.size(); int min = Math.min(fromSize, toSize); int numberOfSubAligns = (int) Math.max(1, min/2); startToIndex = i * toChunkSize; System.out.println("Subaligning FROM("+startFromIndex +","+endFromIndex+") - TO("+startToIndex +","+endToIndex+")"); ArrayList<PathParser.PathDataNode>[] subAlign = doRawAlign(transformFrom.subList(startFromIndex, endFromIndex).toArray(new PathParser.PathDataNode[1]), transformTo.subList(startToIndex, endToIndex).toArray(new PathParser.PathDataNode[1])); finalFrom.addAll(subAlign[0]); finalTo.addAll(subAlign[1]);