Java Code Examples for java.util.SortedSet.contains()

The following are Jave code examples for showing how to use contains() of the java.util.SortedSet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: vexillo   File: EncodingNode.java   View Source Code Vote up 6 votes
public EncodingNode(String[] ids, CodeSequence[] seqs) {
	SortedSet<String> idSet = new TreeSet<String>();
	SortedSet<String> nidSet = new TreeSet<String>();
	for (int i = 0; i < ids.length; i++) {
		String nid = ids[i].toLowerCase().replaceAll("[^a-z0-9]+", "");
		if (ids[i].length() > 0 && nid.length() > 0) {
			if (idSet.contains(ids[i])) throw new IllegalArgumentException("Duplicate id: " + ids[i]);
			if (nidSet.contains(nid)) throw new IllegalArgumentException("Duplicate id:" + nid);
			idSet.add(ids[i]);
			nidSet.add(nid);
		}
	}
	if (idSet.isEmpty() || nidSet.isEmpty()) throw new IllegalArgumentException("No ids");
	this.ids = idSet.toArray(new String[idSet.size()]);
	this.nids = nidSet.toArray(new String[nidSet.size()]);
	SortedSet<CodeSequence> seqSet = new TreeSet<CodeSequence>();
	for (int i = 0; i < seqs.length; i++) {
		if (seqs[i].length() > 0) {
			if (seqSet.contains(seqs[i])) throw new IllegalArgumentException("Duplicate code sequence: " + seqs[i]);
			seqSet.add(seqs[i]);
		}
	}
	if (seqSet.isEmpty()) throw new IllegalArgumentException("No code sequences");
	this.seqs = seqSet.toArray(new CodeSequence[seqSet.size()]);
}
 
Example 2
Project: openjdk-jdk10   File: ClassTree.java   View Source Code Vote up 6 votes
/**
 *  Return the set of classes which implement the interface passed.
 *
 * @param typeElement interface whose implementing-classes set is required.
 */
public SortedSet<TypeElement> implementingClasses(TypeElement typeElement) {
    SortedSet<TypeElement> result = get(implementingClasses, typeElement);
    SortedSet<TypeElement> intfcs = allSubClasses(typeElement, false);

    // If class x implements a subinterface of typeElement, then it follows
    // that class x implements typeElement.
    Iterator<TypeElement> subInterfacesIter = intfcs.iterator();
    while (subInterfacesIter.hasNext()) {
        Iterator<TypeElement> implementingClassesIter
                = implementingClasses(subInterfacesIter.next()).iterator();
        while (implementingClassesIter.hasNext()) {
            TypeElement c = implementingClassesIter.next();
            if (!result.contains(c)) {
                result.add(c);
            }
        }
    }
    return result;
}
 
Example 3
Project: openjdk-jdk10   File: TestBCI.java   View Source Code Vote up 6 votes
void verify(StackFrame frame) {
    if (frame.getDeclaringClass() != clazz)
        return;

    int bci = frame.getByteCodeIndex();
    int lineNumber = frame.getLineNumber();
    System.out.format("%s.%s bci %d (%s:%d)%n",
                      frame.getClassName(), frame.getMethodName(), bci,
                      frame.getFileName(), lineNumber);

    MethodInfo method = methods.get(frame.getMethodName());
    SortedSet<Integer> values = method.findLineNumbers(bci).get();
    if (!values.contains(lineNumber)) {
        throw new RuntimeException("line number for bci: " + bci + " "
            + lineNumber + " not matched line number table: " + values);
    }
}
 
Example 4
Project: ditb   File: TestReplicationSourceManager.java   View Source Code Vote up 6 votes
/**
 * @return 1 when the map is not empty.
 */
private int isLogZnodesMapPopulated() {
  Collection<SortedSet<String>> sets = logZnodesMap.values();
  if (sets.size() > 1) {
    throw new RuntimeException("unexpected size of logZnodesMap: " + sets.size());
  }
  if (sets.size() == 1) {
    SortedSet<String> s = sets.iterator().next();
    for (String file : files) {
      // at least one file was missing
      if (!s.contains(file)) {
        return 0;
      }
    }
    return 1; // we found all the files
  }
  return 0;
}
 
Example 5
Project: vexillo   File: EncodingNode.java   View Source Code Vote up 5 votes
public EncodingNode(String ids, String seqs) {
	SortedSet<String> idSet = new TreeSet<String>();
	SortedSet<String> nidSet = new TreeSet<String>();
	String[] idsArray = ids.split("(\\s|;)+");
	for (String id : idsArray) {
		String nid = id.toLowerCase().replaceAll("[^a-z0-9]+", "");
		if (id.length() > 0 && nid.length() > 0) {
			if (idSet.contains(id)) throw new IllegalArgumentException("Duplicate id: " + id);
			if (nidSet.contains(nid)) throw new IllegalArgumentException("Duplicate id:" + nid);
			idSet.add(id);
			nidSet.add(nid);
		}
	}
	if (idSet.isEmpty() || nidSet.isEmpty()) throw new IllegalArgumentException("No ids");
	this.ids = idSet.toArray(new String[idSet.size()]);
	this.nids = nidSet.toArray(new String[nidSet.size()]);
	SortedSet<CodeSequence> seqSet = new TreeSet<CodeSequence>();
	String[] seqsArray = seqs.split("(\\s|;)+");
	for (String seqString : seqsArray) {
		CodeSequence seq = new CodeSequence(seqString);
		if (seq.length() > 0) {
			if (seqSet.contains(seq)) throw new IllegalArgumentException("Duplicate code sequence: " + seq);
			seqSet.add(seq);
		}
	}
	if (seqSet.isEmpty()) throw new IllegalArgumentException("No code sequences");
	this.seqs = seqSet.toArray(new CodeSequence[seqSet.size()]);
}
 
Example 6
Project: crnk-framework   File: RuntimeClassLoaderFactory.java   View Source Code Vote up 5 votes
public Set<File> getProjectLibraries() {
	Set<File> classpath = new HashSet<>();

	SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");

	if (sourceSets != null) {
		SortedSet<String> availableSourceSetNames = sourceSets.getNames();
		for (String sourceSetName : Arrays.asList("main", "test", "integrationTest")) {
			if (availableSourceSetNames.contains(sourceSetName)) {
				SourceSet sourceSet = sourceSets.getByName(sourceSetName);
				classpath.add(sourceSet.getOutput().getClassesDir());
			}
		}
	}

	// add  dependencies from configured gradle configuration to url (usually test or integrationTest)
	TSGeneratorConfig generatorConfiguration = project.getExtensions().getByType(TSGeneratorConfig.class);
	String configurationName = generatorConfiguration.getRuntime().getConfiguration();

	ConfigurationContainer configurations = project.getConfigurations();
	Configuration runtimeConfiguration = configurations.findByName(configurationName + "Runtime");
	if (runtimeConfiguration == null) {
		runtimeConfiguration = configurations.getByName(configurationName);
	}
	classpath.addAll(runtimeConfiguration.getFiles());

	for (File file : classpath) {
		LOGGER.debug("classpath entry: {}", file);
	}

	return classpath;
}
 
Example 7
Project: monarch   File: PdxInstanceImpl.java   View Source Code Vote up 5 votes
/**
 * Any fields that are in otherFields but not in myFields are added to myFields as defaults. When
 * adding fields they are inserted in the natural sort order. Note: myFields may be modified by
 * this call.
 */
private static void addDefaultFields(SortedSet<PdxField> myFields,
    SortedSet<PdxField> otherFields) {
  for (PdxField f : otherFields) {
    if (!myFields.contains(f)) {
      myFields.add(new DefaultPdxField(f));
    }
  }
}
 
Example 8
Project: openjdk-jdk10   File: ClassTree.java   View Source Code Vote up 5 votes
/**
 * Adjust the Class Tree. Add the class interface  in to it's super classes
 * or super interface's sub-interface set.
 *
 * @param map the entire map.
 * @param superclass java.lang.Object or the super-interface.
 * @param typeElement sub-interface to be mapped.
 * @returns boolean true if class added, false if class already processed.
 */
private boolean add(Map<TypeElement, SortedSet<TypeElement>> map, TypeElement superclass, TypeElement typeElement) {
    SortedSet<TypeElement> sset = map.computeIfAbsent(superclass, s ->  new TreeSet<>(comparator));
    if (sset.contains(typeElement)) {
        return false;
    } else {
        sset.add(typeElement);
    }
    return true;
}
 
Example 9
Project: hadoop   File: LayoutVersion.java   View Source Code Vote up 2 votes
/**
 * Returns true if a given feature is supported in the given layout version
 * @param map layout feature map
 * @param f Feature
 * @param lv LayoutVersion
 * @return true if {@code f} is supported in layout version {@code lv}
 */
public static boolean supports(Map<Integer, SortedSet<LayoutFeature>> map,
    final LayoutFeature f, final int lv) {
  final SortedSet<LayoutFeature> set =  map.get(lv);
  return set != null && set.contains(f);
}