/** Cleans up resources to avoid excessive memory usage. */ public void cleanUp() { topSnapshot.set(null); singleMsgs.clear(); fullMsgs.clear(); rcvdIds.clear(); oldestNode.set(null); partReleaseFut = null; Collection<ClusterNode> rmtNodes = this.rmtNodes; if (rmtNodes != null) rmtNodes.clear(); }
public static void main(String[] args) { Collection c = new ArrayList(); // 添加元素 c.add("孙悟空"); // 虽然集合里不能放基本类型的值,但Java支持自动装箱 c.add(6); System.out.println("c集合的元素个数为:" + c.size()); // 删除指定元素 c.remove(6); System.out.println("c集合的元素个数为:" + c.size()); // 判断是否包含指定字符串 System.out.println("c集合的是否包含\"孙悟空\"字符串:" + c.contains("孙悟空")); c.add("轻量级Java EE企业应用实战"); System.out.println("c集合的元素:" + c); Collection books = new HashSet(); books.add("轻量级Java EE企业应用实战"); books.add("疯狂Java讲义"); System.out.println("c集合是否完全包含books集合?" + c.containsAll(books)); // 用c集合减去books集合里的元素 c.removeAll(books); System.out.println("c集合的元素:" + c); // 删除c集合里所有元素 c.clear(); System.out.println("c集合的元素:" + c); // books集合里只剩下c集合里也包含的元素 books.retainAll(c); System.out.println("books集合的元素:" + books); }
// look up and apply coarts for given rels to each sign in result private void applyCoarts(List<String> coartRels, Collection<Sign> result) { List<Sign> inputSigns = new ArrayList<Sign>(result); result.clear(); List<Sign> outputSigns = new ArrayList<Sign>(inputSigns.size()); // for each rel, lookup coarts and apply to input signs, storing results in output signs for (Iterator<String> it = coartRels.iterator(); it.hasNext(); ) { String rel = it.next(); Collection<String> preds = (Collection<String>) _coartRelsToPreds.get(rel); if (preds == null) continue; // not expected Collection<Sign> coartResult = getSignsFromRelAndPreds(rel, preds); if (coartResult == null) continue; for (Iterator<Sign> it2 = coartResult.iterator(); it2.hasNext(); ) { Sign coartSign = it2.next(); // apply to each input for (int j = 0; j < inputSigns.size(); j++) { Sign sign = inputSigns.get(j); grammar.rules.applyCoart(sign, coartSign, outputSigns); } } // switch output to input for next iteration inputSigns.clear(); inputSigns.addAll(outputSigns); outputSigns.clear(); } // add results back result.addAll(inputSigns); }
/** @param cnt Count. */ private void checkPoll(int cnt) { init(); int step = 10; assert cnt % step == 0; Collection<Long> set = new HashSet<>(step); for (int i = 0; i < cnt; i++) lru.offer(0, i, i); assertEquals(cnt, lru.size()); for (int i = 0; i < cnt; i += step) { for (int j = 0; j < step; j++) { long qAddr = lru.prePoll(); assertTrue(qAddr != 0); assertTrue(set.add(qAddr)); } for (long qAddr : set) lru.poll(qAddr); set.clear(); } assertEquals(0, lru.size()); }
private static void copyCollection( Object target, String[] effectiveProperties, String[] ignoreProperties, Boolean nullBeCopied, PropertyDescriptor targetPd, Object sourceValue, Method writeMethod) throws IllegalAccessException, InvocationTargetException, UtilException, ClassNotFoundException, InstantiationException, NoSuchFieldException { Method targetReadMethod = targetPd.getReadMethod(); Collection targetValue = (Collection) targetReadMethod.invoke(target, null); List tempList = new ArrayList(); if (sourceValue == null) { writeMethod.invoke(target, sourceValue); return; } if (targetValue == null) { if (Set.class.isAssignableFrom(targetPd.getPropertyType())) { targetValue = new HashSet(); } else if (List.class.isAssignableFrom(targetPd.getPropertyType())) { targetValue = new ArrayList(); } else { return; } } Object[] sourceArray = ((Collection) sourceValue).toArray(); Object[] targetArray = targetValue.toArray(); for (int i = 0; i < sourceArray.length; i++) { if (targetValue.contains(sourceArray[i])) { for (int j = 0; j < targetArray.length; j++) { if (sourceArray[i].equals(targetArray[j])) { copyProperties( sourceArray[i], targetArray[j], effectiveProperties, ignoreProperties, nullBeCopied); tempList.add(targetArray[j]); break; } } } else { Object tempTarget = Class.forName(sourceArray[i].getClass().getName()).newInstance(); // 基本类型直接赋值 if (sourceArray[i].getClass().isPrimitive() || sourceArray[i] instanceof String) { tempTarget = sourceArray[i]; } else { copyProperties( sourceArray[i], tempTarget, effectiveProperties, ignoreProperties, nullBeCopied); } tempList.add(tempTarget); } } targetValue.clear(); targetValue.addAll(tempList); return; }
void collectItems() { if (!myBreakpointsPanelProviders.isEmpty()) { myBreakpointItems.clear(); for (BreakpointPanelProvider panelProvider : myBreakpointsPanelProviders) { panelProvider.provideBreakpointItems(myProject, myBreakpointItems); } } }
@SuppressWarnings("squid:S1244") private static String selectBestEncoding(String acceptEncodingHeader) { // multiple encodings are accepted; determine best one Collection<String> bestEncodings = new HashSet<>(3); double bestQ = 0.0; Collection<String> unacceptableEncodings = new HashSet<>(3); boolean willAcceptAnything = false; for (String token : COMMA.split(acceptEncodingHeader)) { ContentEncodingQ contentEncodingQ = parseContentEncodingQ(token); String contentEncoding = contentEncodingQ.getContentEncoding(); double q = contentEncodingQ.getQ(); if (ANY_ENCODING.equals(contentEncoding)) { willAcceptAnything = q > 0.0; } else if (SUPPORTED_ENCODINGS.contains(contentEncoding)) { if (q > 0.0) { // This is a header quality comparison. // So it is safe to suppress warning squid:S1244 if (q == bestQ) { bestEncodings.add(contentEncoding); } else if (q > bestQ) { bestQ = q; bestEncodings.clear(); bestEncodings.add(contentEncoding); } } else { unacceptableEncodings.add(contentEncoding); } } } if (bestEncodings.isEmpty()) { // nothing was acceptable to us if (willAcceptAnything) { if (unacceptableEncodings.isEmpty()) { return SUPPORTED_ENCODINGS.get(0); } else { for (String encoding : SUPPORTED_ENCODINGS) { if (!unacceptableEncodings.contains(encoding)) { return encoding; } } } } } else { for (String encoding : SUPPORTED_ENCODINGS) { if (bestEncodings.contains(encoding)) { return encoding; } } } return NO_ENCODING; }
/** * This method is the access point to the planning procedure. Initially, it adds all variables * from axioms to the set of found vars, then does the linear planning. If lp does not solve the * problem and there are subtasks, goal-driven recursive planning with backtracking is invoked. * Planning is performed until no new variables are introduced into the algorithm. */ public EvaluationAlgorithm invokePlaning(Problem problem, boolean _computeAll) { long startTime = System.currentTimeMillis(); computeAll = _computeAll; EvaluationAlgorithm algorithm = new EvaluationAlgorithm(); PlanningContext context = problem.getCurrentContext(); // add all axioms at the beginning of an algorithm Collection<Var> flattened = new HashSet<Var>(); for (Iterator<Rel> axiomIter = problem.getAxioms().iterator(); axiomIter.hasNext(); ) { Rel rel = axiomIter.next(); unfoldVarsToSet(rel.getOutputs(), flattened); // do not overwrite values of variables that come via args of compute() or as inputs of // independent subtasks if (!problem.getAssumptions().containsAll(flattened) // do not overwrite values of already known variables. // typically this is the case when a value of a variable // is given in a scheme via a properties window // && !problem.getKnownVars().containsAll( flattened ) ) { algorithm.addRel(rel); } axiomIter.remove(); context.getKnownVars().addAll(flattened); flattened.clear(); } context.getFoundVars().addAll(context.getKnownVars()); // remove all known vars with no relations for (Iterator<Var> varIter = context.getKnownVars().iterator(); varIter.hasNext(); ) { if (varIter.next().getRels().isEmpty()) { varIter.remove(); } } // start planning if (problem.getRelsWithSubtasks().isEmpty() && linearForwardSearch(context, algorithm, computeAll)) { if (isLinearLoggingOn()) logger.debug("Problem solved without subtasks"); } else if (!problem.getRelsWithSubtasks().isEmpty() && subtaskPlanning(problem, algorithm)) { if (isLinearLoggingOn()) logger.debug("Problem solved with subtasks"); } else if (!computeAll) { if (isLinearLoggingOn()) logger.debug("Problem not solved"); } if (!nested) { logger.info("Planning time: " + (System.currentTimeMillis() - startTime) + "ms."); } return algorithm; }
@Override protected void addReferenceAtCaret(Collection<PsiReference> refs) { final V variable = getLocalVariable(); if (variable != null) { for (PsiReference reference : ReferencesSearch.search(variable)) { refs.add(reference); } } else { refs.clear(); } }
@SmallTest @MediumTest @LargeTest public void testCollectionClearThrows() throws JSONException { try { Collection<Integer> collection = GraphObject.Factory.createList(Integer.class); collection.clear(); fail("Expected exception"); } catch (UnsupportedOperationException exception) { } }
/** Clear list of status presets. */ public void clearSavedStatuses() { savedStatuses.clear(); Application.getInstance() .runInBackground( new Runnable() { @Override public void run() { StatusTable.getInstance().clear(); } }); }
public static void shutdown() { for (ConnectionWrapper conn : connectionPool) { if (conn != null) { try { conn.reallyClose(); } catch (SQLException e) { } } } connectionPool.clear(); }
// FIXME: does not integrate with recursive session method calls: recursionEnter/Exit and also // recurse do not match the control flow of recursive calls, and hence runtime type monitoring // does not work. private Node translateSJRecursion(SJRecursion r, QQ qq) // recursionEnter inserted by node factory, but translation is finished here.. { SJSessionOperationExt soe = getSJSessionOperationExt(r); Position pos = r.position(); Collection<Object> mapping = new LinkedList<Object>(); String bname = getRecursionBooleanName(soe.targetNames(), r.label()); mapping.add(bname); mapping.add(bname); String translation = "for (boolean %s = true; %s; ) { }"; For f = (For) qq.parseStmt(translation, mapping.toArray()); mapping.clear(); r = (SJRecursion) r.inits(f.inits()); r = (SJRecursion) r.cond(f.cond()); List stmts = new LinkedList(); stmts.addAll(r.body().statements()); translation = "%s = %E;"; mapping.add(bname); mapping.add(((Eval) stmts.remove(0)).expr()); // Factor out constant. Eval e = (Eval) qq.parseStmt(translation, mapping.toArray()); stmts.add(0, e); r = (SJRecursion) r.body(sjnf.Block(pos, stmts)); /*// Appending the recursion-exit hook. // Disabled to support delegation from within recursion scopes (socket will be null on recursion-exit). List<Local> targets = new LinkedList<Local>(); // FIXME: should be SJLocalSockets. for (String sjname : soe.targetNames()) // Unicast optimisation for SJRecursionExit is done within the NodeFactory method - this pass comes after SJUnicastOptimiser. { targets.add(sjnf.Local(pos, sjnf.Id(pos, sjname))); // Would it be bad to instead alias the recursionEnter targets? } SJRecursionExit re = sjnf.SJRecursionExit(pos, targets); // Problem: the sockets argument array is not yet filled (for other (internal) basic operations, this was done earlier by SJSessionOperationParser)... re = (SJRecursionExit) SJVariableParser.parseSJSessionOperation(this, re); // ...Current fix: use those routines form those earlier passes. re = (SJRecursionExit) SJSessionOperationParser.fixSJBasicOperationArguments(this, re);*/ // return sjnf.Block(pos, r, sjnf.Eval(pos, re)); return sjnf.Block(pos, r); }
private void ruin( Collection<VehicleRoute> vehicleRoutes, int nOfJobs2BeRemoved, List<Job> unassignedJobs) { if (vrp.getJobs().values().size() == 0) return; Map<Job, VehicleRoute> mappedRoutes = map(vehicleRoutes); int toRemove = nOfJobs2BeRemoved; Collection<Job> lastRemoved = new ArrayList<Job>(); Set<VehicleRoute> ruined = new HashSet<VehicleRoute>(); Set<Job> removed = new HashSet<Job>(); Set<VehicleRoute> cycleCandidates = new HashSet<VehicleRoute>(); while (toRemove > 0) { Job target; VehicleRoute targetRoute = null; if (lastRemoved.isEmpty()) { target = RandomUtils.nextJob(vrp.getJobs().values(), random); targetRoute = mappedRoutes.get(target); } else { target = RandomUtils.nextJob(lastRemoved, random); Iterator<Job> neighborIterator = jobNeighborhoods.getNearestNeighborsIterator(nOfJobs2BeRemoved, target); while (neighborIterator.hasNext()) { Job j = neighborIterator.next(); if (!removed.contains(j) && !ruined.contains(mappedRoutes.get(j))) { targetRoute = mappedRoutes.get(j); break; } } lastRemoved.clear(); } if (targetRoute == null) break; if (cycleCandidates.contains(targetRoute)) break; if (ruined.contains(targetRoute)) { cycleCandidates.add(targetRoute); break; } DBSCANClusterer dbscan = new DBSCANClusterer(vrp.getTransportCosts()); dbscan.setRandom(random); dbscan.setMinPts(minPts); dbscan.setEpsFactor(epsFactor); List<Job> cluster = dbscan.getRandomCluster(targetRoute); for (Job j : cluster) { if (toRemove == 0) break; if (removeJob(j, vehicleRoutes)) { lastRemoved.add(j); unassignedJobs.add(j); } toRemove--; } ruined.add(targetRoute); } }
private static void removeSearchHighlight(@NotNull Editor editor) { Collection<RangeHighlighter> ehl = EditorData.getLastHighlights(editor); if (ehl == null) { return; } for (RangeHighlighter rh : ehl) { editor.getMarkupModel().removeHighlighter(rh); } ehl.clear(); EditorData.setLastHighlights(editor, null); EditorData.setLastSearch(editor, null); }
public void removeExcluded( @NotNull Collection<VirtualFile> files, final FrameworkType frameworkType) { ensureOldSettingsLoaded(); if (myExcludedFrameworks.contains(frameworkType.getId())) { files.clear(); return; } final Iterator<VirtualFile> iterator = files.iterator(); while (iterator.hasNext()) { VirtualFile file = iterator.next(); if (isFileExcluded(file, frameworkType.getId())) { iterator.remove(); } } }
/** * loads a pluginSet xml file and updates the model to reflect certain checked selections * * @since jEdit 4.3pre10 * @author Alan Ezust */ boolean loadPluginSet(String path) { pluginSet.clear(); pluginModel.restoreSelection(new HashSet<String>(), new HashSet<String>()); VFS vfs = VFSManager.getVFSForPath(path); Object session = vfs.createVFSSession(path, InstallPanel.this); try { InputStream is = vfs._createInputStream(session, path, false, InstallPanel.this); XMLUtilities.parseXML(is, new StringMapHandler()); } catch (Exception e) { Log.log(Log.WARNING, this, "Loading Pluginset failed:" + e.getMessage()); return false; } pluginModel.update(); return true; } // }}}
/** * @param name 为 null 时指代文件起首的全局 sector(无名称) * @return true, 内容被更改 */ public boolean removeSector(String name) { if (name == null) { globalLines.clear(); dirty = true; return true; } Iterator<Sector> iter = sectors.iterator(); while (iter.hasNext()) { Sector s = iter.next(); if (s.name.equals(name)) { iter.remove(); dirty = true; return true; } } return false; }
public void readExternal(Element parentNode) throws InvalidDataException { myDisabledHintsFiles.clear(); Element element = parentNode.getChild(DISABLE_HINTS_TAG); if (element != null) { for (Object o : element.getChildren(FILE_TAG)) { Element e = (Element) o; String url = e.getAttributeValue(URL_ATT); if (url != null) { VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url); if (file != null) { myDisabledHintsFiles.add(file); } } } } }
private void splitAggregationStoragesAndSend( String name, AggregationStorageMetadata metadata, AggregationStorage aggregationStorage) { Configuration conf = Configuration.get(); int numSplits = metadata.getNumSplits(); if (numSplits == 1) { AggregationStorageWrapper aggWrapper = new AggregationStorageWrapper(aggregationStorage); super.setAggregatedValue(conf.getAggregationSplitName(name, 0), aggWrapper); } else { Collection<Writable> keysToTransfer = new ArrayList<>(aggregationStorage.getNumberMappings()); for (int i = 0; i < numSplits; ++i) { AggregationStorage aggStorageSplit = aggregationStorageFactory.createAggregationStorage(name); AggregationStorageWrapper aggStorageSplitWrapper = new AggregationStorageWrapper(aggStorageSplit); keysToTransfer.clear(); for (Object key : aggregationStorage.getKeys()) { int owner = key.hashCode() % numSplits; if (owner < 0) { owner += numSplits; } if (owner != i) { continue; } keysToTransfer.add((Writable) key); } for (Writable key : keysToTransfer) { aggStorageSplit.transferKeyFrom(key, aggregationStorage); } super.setAggregatedValue(conf.getAggregationSplitName(name, i), aggStorageSplitWrapper); } } }
public Object down(Event evt) { switch (evt.getType()) { case Event.VIEW_CHANGE: View view = evt.getArg(); List<Address> mbrs = view.getMembers(); members.clear(); members.addAll(mbrs); // ignoredMembers.retainAll(mbrs); // remove all non members if (discard_dialog != null) discard_dialog.handleView(mbrs); break; case Event.SET_LOCAL_ADDRESS: localAddress = evt.getArg(); if (discard_dialog != null) discard_dialog.setTitle("Discard dialog (" + localAddress + ")"); break; case Event.GET_PING_DATA: if (discard_all) return null; break; } return down_prot.down(evt); }
/** * {@inheritDoc} * * <p>Downcast {@link org.springframework.web.bind.WebDataBinder} to {@link * org.springframework.web.bind.ServletRequestDataBinder} before binding. * * @throws Exception * @see org.springframework.web.servlet.mvc.method.annotation.ServletRequestDataBinderFactory */ protected void bindRequestParameters( ModelAndViewContainer mavContainer, WebDataBinderFactory binderFactory, WebDataBinder binder, NativeWebRequest request, MethodParameter parameter) throws Exception { Map<String, Boolean> hasProcessedPrefixMap = new HashMap<String, Boolean>(); Class<?> targetType = binder.getTarget().getClass(); ServletRequest servletRequest = prepareServletRequest(binder.getTarget(), request, parameter); WebDataBinder simpleBinder = binderFactory.createBinder(request, null, null); if (Collection.class.isAssignableFrom(targetType)) { // bind collection or array Type type = parameter.getGenericParameterType(); Class<?> componentType = Object.class; Collection target = (Collection) binder.getTarget(); List targetList = new ArrayList(target); if (type instanceof ParameterizedType) { componentType = (Class<?>) ((ParameterizedType) type).getActualTypeArguments()[0]; } if (parameter.getParameterType().isArray()) { componentType = parameter.getParameterType().getComponentType(); } for (Object key : servletRequest.getParameterMap().keySet()) { String prefixName = getPrefixName((String) key); // 每个prefix 只处理一次 if (hasProcessedPrefixMap.containsKey(prefixName)) { continue; } else { hasProcessedPrefixMap.put(prefixName, Boolean.TRUE); } if (isSimpleComponent(prefixName)) { // bind simple type Map<String, Object> paramValues = WebUtils.getParametersStartingWith(servletRequest, prefixName); Matcher matcher = INDEX_PATTERN.matcher(prefixName); if (!matcher.matches()) { // 处理如 array=1&array=2的情况 for (Object value : paramValues.values()) { targetList.add(simpleBinder.convertIfNecessary(value, componentType)); } } else { // 处理如 array[0]=1&array[1]=2的情况 int index = Integer.valueOf(matcher.group(1)); if (targetList.size() <= index) { growCollectionIfNecessary(targetList, index); } targetList.set( index, simpleBinder.convertIfNecessary(paramValues.values(), componentType)); } } else { // 处理如 // votes[1].title=votes[1].title&votes[0].title=votes[0].title&votes[0].id=0&votes[1].id=1 Object component = null; // 先查找老的 即已经在集合中的数据(而不是新添加一个) Matcher matcher = INDEX_PATTERN.matcher(prefixName); if (!matcher.matches()) { throw new IllegalArgumentException( "bind collection error, need integer index, key:" + key); } int index = Integer.valueOf(matcher.group(1)); if (targetList.size() <= index) { growCollectionIfNecessary(targetList, index); } Iterator iterator = targetList.iterator(); for (int i = 0; i < index; i++) { iterator.next(); } component = iterator.next(); if (component == null) { component = BeanUtils.instantiate(componentType); } WebDataBinder componentBinder = binderFactory.createBinder(request, component, null); component = componentBinder.getTarget(); if (component != null) { ServletRequestParameterPropertyValues pvs = new ServletRequestParameterPropertyValues(servletRequest, prefixName, ""); componentBinder.bind(pvs); validateIfApplicable(componentBinder, parameter); if (componentBinder.getBindingResult().hasErrors()) { if (isBindExceptionRequired(componentBinder, parameter)) { throw new BindException(componentBinder.getBindingResult()); } } targetList.set(index, component); } } target.clear(); target.addAll(targetList); } } else if (MapWapper.class.isAssignableFrom(targetType)) { Type type = parameter.getGenericParameterType(); Class<?> keyType = Object.class; Class<?> valueType = Object.class; if (type instanceof ParameterizedType) { keyType = (Class<?>) ((ParameterizedType) type).getActualTypeArguments()[0]; valueType = (Class<?>) ((ParameterizedType) type).getActualTypeArguments()[1]; } MapWapper mapWapper = ((MapWapper) binder.getTarget()); Map target = mapWapper.getInnerMap(); if (target == null) { target = new HashMap(); mapWapper.setInnerMap(target); } for (Object key : servletRequest.getParameterMap().keySet()) { String prefixName = getPrefixName((String) key); // 每个prefix 只处理一次 if (hasProcessedPrefixMap.containsKey(prefixName)) { continue; } else { hasProcessedPrefixMap.put(prefixName, Boolean.TRUE); } Object keyValue = simpleBinder.convertIfNecessary(getMapKey(prefixName), keyType); if (isSimpleComponent(prefixName)) { // bind simple type Map<String, Object> paramValues = WebUtils.getParametersStartingWith(servletRequest, prefixName); for (Object value : paramValues.values()) { target.put(keyValue, simpleBinder.convertIfNecessary(value, valueType)); } } else { Object component = target.get(keyValue); if (component == null) { component = BeanUtils.instantiate(valueType); } WebDataBinder componentBinder = binderFactory.createBinder(request, component, null); component = componentBinder.getTarget(); if (component != null) { ServletRequestParameterPropertyValues pvs = new ServletRequestParameterPropertyValues(servletRequest, prefixName, ""); componentBinder.bind(pvs); validateComponent(componentBinder, parameter); target.put(keyValue, component); } } } } else { // bind model ServletRequestDataBinder servletBinder = (ServletRequestDataBinder) binder; servletBinder.bind(servletRequest); } }
public void initiate(int origin) { this.origin = origin; currentCity = origin; edges.clear(); }
public void reset() { if (myOffsetRespBlocks != EMPTY) myOffsetRespBlocks.clear(); }
public void clear() { activateForWrite(); _delegate.clear(); }
/** 清除所有内容 */ public void clear() { globalLines.clear(); sectors.clear(); dirty = true; }
public static Object element(Object arg, ExecutionContext context) throws FunctionDomainException, TypeMismatchException { if (arg == null || arg == QueryService.UNDEFINED) return QueryService.UNDEFINED; if (arg instanceof Collection) { Collection c = (Collection) arg; // for remote distinct queries, the result of sub query could contain a // mix of String and PdxString which could be duplicates, so convert all // PdxStrings to String if (context.isDistinct() && ((DefaultQuery) context.getQuery()).isRemoteQuery()) { Set tempResults = new HashSet(); for (Object o : c) { if (o instanceof PdxString) { o = ((PdxString) o).toString(); } tempResults.add(o); } c.clear(); c.addAll(tempResults); tempResults = null; } checkSingleton(c.size()); return c.iterator().next(); } // not a Collection, must be an array Class clazz = arg.getClass(); if (!clazz.isArray()) throw new TypeMismatchException( LocalizedStrings.Functions_THE_ELEMENT_FUNCTION_CANNOT_BE_APPLIED_TO_AN_OBJECT_OF_TYPE_0 .toLocalizedString(clazz.getName())); // handle arrays if (arg instanceof Object[]) { Object[] a = (Object[]) arg; if (((DefaultQuery) context.getQuery()).isRemoteQuery() && context.isDistinct()) { for (int i = 0; i < a.length; i++) { if (a[i] instanceof PdxString) { a[i] = ((PdxString) a[i]).toString(); } } } checkSingleton(a.length); return a[0]; } if (arg instanceof int[]) { int[] a = (int[]) arg; checkSingleton(a.length); return Integer.valueOf(a[0]); } if (arg instanceof long[]) { long[] a = (long[]) arg; checkSingleton(a.length); return Long.valueOf(a[0]); } if (arg instanceof boolean[]) { boolean[] a = (boolean[]) arg; checkSingleton(a.length); return Boolean.valueOf(a[0]); } if (arg instanceof byte[]) { byte[] a = (byte[]) arg; checkSingleton(a.length); return Byte.valueOf(a[0]); } if (arg instanceof char[]) { char[] a = (char[]) arg; checkSingleton(a.length); return new Character(a[0]); } if (arg instanceof double[]) { double[] a = (double[]) arg; checkSingleton(a.length); return Double.valueOf(a[0]); } if (arg instanceof float[]) { float[] a = (float[]) arg; checkSingleton(a.length); return new Float(a[0]); } if (arg instanceof short[]) { short[] a = (short[]) arg; checkSingleton(a.length); return new Short(a[0]); } // did I miss something? throw new TypeMismatchException( LocalizedStrings.Functions_THE_ELEMENT_FUNCTION_CANNOT_BE_APPLIED_TO_AN_OBJECT_OF_TYPE_0 .toLocalizedString(clazz.getName())); }
public void clear() { for (Collection<PsiElement> elements : groupedByValue) { elements.clear(); } }
/** @throws Exception Thrown if test failed. */ public void testA() throws Exception { Collection<Integer> set = new GridConcurrentWeakHashSet<>(); Integer i = 1; assert set.add(i); assert !set.add(i); assert set.contains(i); assert set.size() == 1; Collection<Integer> c = F.asList(2, 3, 4, 5); assert set.addAll(c); assert !set.addAll(c); assert set.containsAll(c); assert set.size() == 1 + c.size(); assert set.remove(i); assert !set.remove(i); assert !set.contains(i); assert set.size() == c.size(); assert set.removeAll(c); assert !set.removeAll(c); assert !set.containsAll(c); assert set.isEmpty(); Collection<Integer> c1 = Arrays.asList(1, 3, 5, 7, 9); int cnt = 0; for (Iterator<Integer> iter = set.iterator(); iter.hasNext(); cnt++) c1.contains(iter.next()); assert set.size() == cnt; assert set.size() == set.toArray().length; assert set.addAll(c1); assert set.retainAll(c); assert !set.retainAll(c); Collection<Integer> c2 = F.retain(c1, true, c); assert set.containsAll(c2); assert !set.containsAll(c1); assert !set.containsAll(c); assert set.size() == c2.size(); set.clear(); assert set.isEmpty(); try { set.iterator().next(); assert false; } catch (NoSuchElementException ignored) { assert true; } try { set.add(null); assert false; } catch (NullPointerException ignored) { assert true; } }
public void resetImportHintsEnabledForProject() { myDisabledHintsFiles.clear(); }