private static void addNamedGroups(Pattern pattern, HashSet<String> variables) { Matcher matcher = NAMED_GROUPS_PATTERN.matcher(pattern.toString()); while (matcher.find()) { String name = matcher.group(1); checkArgument(!variables.contains(name), "Multiple definitions found for variable ${" + name + "}"); variables.add(name); } }
public Set<String> checkDupColumnNames(){ HashSet<String> uniqueNames = new HashSet<String>(); HashSet<String> conflictingNames = new HashSet<String>(); if(_header){ for(String n:_columnNames){ if(!uniqueNames.contains(n)){ uniqueNames.add(n); } else { conflictingNames.add(n); } } } return conflictingNames; } @Override public ParserSetup clone(){
/** * Counts profile properties. Note: this method is not * that easy on execution. */ public int countProfileProperties() { final HashSet<String> profileKeys = new HashSet<>(); for (final Map<String, PropsEntry> map : profileProperties.values()) { for (final String key : map.keySet()) { if (!baseProperties.containsKey(key)) { profileKeys.add(key); } } } return profileKeys.size(); }
public static void addParameterizedSupertypes(TypeDecl t, HashSet processed, HashSet result) { if(!processed.contains(t)) { processed.add(t); if(t.isParameterizedType() /*&& !t.isRawType()*/) result.add(t); for(Iterator iter = directSupertypes(t).iterator(); iter.hasNext(); ) { TypeDecl typeDecl = (TypeDecl)iter.next(); addParameterizedSupertypes(typeDecl, processed, result); } } }
/** * generates randomly N distinct integers from 0 to Max. */ static int[] generateUniformHash(Random rand, int N, int Max) { if (N > Max) throw new RuntimeException("not possible"); if (N > Max / 2) { return negate(generateUniformHash(rand, Max - N, Max), Max); } int[] ans = new int[N]; HashSet<Integer> s = new HashSet<Integer>(); while (s.size() < N) s.add(new Integer(rand.nextInt(Max))); Iterator<Integer> i = s.iterator(); for (int k = 0; k < N; ++k) ans[k] = i.next().intValue(); Arrays.sort(ans); return ans; }
@Override protected int act(List<Run<?, ?>> builds) throws IOException { job.checkPermission(Run.DELETE); final HashSet<Integer> hsBuilds = new HashSet<>(); for (Run<?, ?> build : builds) { if (!hsBuilds.contains(build.number)) { build.delete(); hsBuilds.add(build.number); } } stdout.println("Deleted "+hsBuilds.size()+" builds"); return 0; }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(); MultipartHttpServletRequest httpServletRequest = multipartResolver.resolveMultipart(request); Map<String, MultipartFile> map = httpServletRequest.getFileMap(); MultipartFile multipartFile = map.values().iterator().next(); receivedFiles.add(multipartFile.getOriginalFilename()); }
private void validatePipelineUniqueness(ErrorCollection errors, String location) { HashSet<String> keys = new HashSet<>(); for(String pipeline : pipelines) { String lowerCase = pipeline.toLowerCase(); if(keys.contains(lowerCase)) errors.addError(location,String.format( "Pipeline %s is defined more than once",pipeline)); else keys.add(lowerCase); } }
public String[] getPropertyGroups(String prefix) { Enumeration<?> keys = props.propertyNames(); HashSet<String> groups = new HashSet<String>(10); if (!prefix.endsWith(".")) { prefix += "."; } while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); if (key.startsWith(prefix)) { String groupName = key.substring(prefix.length(), key.indexOf( '.', prefix.length())); groups.add(groupName); } } return (String[]) groups.toArray(new String[groups.size()]); }
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { String fieldDesc = className + ":" + name + ":" + desc; if (!refFieldSet.contains(fieldDesc)) { refFieldSet.add(fieldDesc); fieldCount++; } return super.visitField(access, name, desc, signature, value); } };
private int getUniqueNodeCount(List<RebalanceTaskInfo> rebalanceInfoList, boolean isDonorBased) { HashSet<Integer> uniqueNodeSet = Sets.newHashSet(); for(RebalanceTaskInfo partitionInfo: rebalanceInfoList) { int nodeId; if(isDonorBased) { nodeId = partitionInfo.getDonorId(); } else { nodeId = partitionInfo.getStealerId(); } if(!uniqueNodeSet.contains(nodeId)) { uniqueNodeSet.add(nodeId); } } return uniqueNodeSet.size(); }