java.util.TreeSet#toString ( )源码实例Demo

下面列出了java.util.TreeSet#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: qpid-broker-j   文件: HttpManagementUtil.java
public static String getRequestPrincipals(HttpServletRequest httpRequest)
{
    HttpSession session = httpRequest.getSession(false);
    if (session != null)
    {
        Subject subject = HttpManagementUtil.getAuthorisedSubject(httpRequest);
        if (subject != null)
        {

            Set<Principal> principalSet = subject.getPrincipals();
            if (!principalSet.isEmpty())
            {
                TreeSet<String> principalNames = new TreeSet<>();
                for (Principal principal : principalSet)
                {
                    principalNames.add(principal.getName());
                }
                return principalNames.toString();
            }
        }
    }
    return null;
}
 
源代码2 项目: UVA   文件: 11286 Confirmity.java
public static void main (String [] args) throws Exception {
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	String s;
	while (!(s=br.readLine()).equals("0")){
		int n=Integer.parseInt(s);
		HashMap<String,Integer> map=new HashMap<>();

		for (int i=0;i<n;i++) {
			StringTokenizer st=new StringTokenizer(br.readLine());
			TreeSet<String> set=new TreeSet<>();
			for (int i2=0;i2<5;i2++) set.add(st.nextToken());
			String key=set.toString();
			map.put(key, map.getOrDefault(key,0)+1);
		}
		
		int max=Collections.max(map.values());
		System.out.println(map.values().stream().filter(i -> i == max).count()*max);
	}
}
 
源代码3 项目: openjdk-jdk9   文件: Test4058433.java
private static void print(FeatureDescriptor descriptor) {
    String name = descriptor.getName();
    String display = descriptor.getDisplayName();
    String description = descriptor.getShortDescription();
    System.out.println("name: " + name);
    if (!Objects.equals(name, display)) {
        System.out.println("display name: " + display);
    }
    if (!Objects.equals(display, description)) {
        System.out.println("description: " + description.trim());
    }
    print("expert", descriptor.isExpert());
    print("hidden", descriptor.isHidden());
    print("preferred", descriptor.isPreferred());
    TreeMap<String,Object> map = new TreeMap<>();
    Enumeration<String> enumeration = descriptor.attributeNames();
    while (enumeration.hasMoreElements()) {
        String id = enumeration.nextElement();
        Object value = descriptor.getValue(id);
        if (value.getClass().isArray()) {
            TreeSet<String> set = new TreeSet<>();
            int index = 0;
            int length = Array.getLength(value);
            while (index < length) {
                set.add(Array.get(value, index++) + ", " +
                        Array.get(value, index++) + ", " +
                        Array.get(value, index++));
            }
            value = set.toString();
        }
        map.put(id, value);
    }
    for (Entry<String,Object> entry : map.entrySet()) {
        System.out.println(entry.getKey() + ": " + entry.getValue());
    }
}
 
源代码4 项目: openjdk-jdk9   文件: TreeSetTest.java
/**
 * toString contains toStrings of elements
 */
public void testToString() {
    TreeSet q = populatedSet(SIZE);
    String s = q.toString();
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(s.contains(String.valueOf(i)));
    }
}
 
源代码5 项目: Ngram-Graphs   文件: casc.java
public Triplet(String sV1, String sV2, String sV3) {
    TreeSet tsSet = new TreeSet();
    tsSet.add(sV1 + "_");
    tsSet.add(sV2 + "_");
    tsSet.add(sV3 + "_");
    
    sString = tsSet.toString();
}
 
源代码6 项目: Ngram-Graphs   文件: casc.java
public Triplet(String sV1, String sV2, String sV3) {
    TreeSet tsSet = new TreeSet();
    tsSet.add(sV1 + "_");
    tsSet.add(sV2 + "_");
    tsSet.add(sV3 + "_");
    
    sString = tsSet.toString();
}
 
源代码7 项目: minperf   文件: LargeSetTest.java
private static String toString(LongSet set) {
    TreeSet<Long> s2 = new TreeSet<Long>();
    for (long x : set) {
        s2.add(x);
    }
    return s2.toString();
}
 
源代码8 项目: j2objc   文件: TreeSetTest.java
/**
 * toString contains toStrings of elements
 */
public void testToString() {
    TreeSet q = populatedSet(SIZE);
    String s = q.toString();
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(s.contains(String.valueOf(i)));
    }
}
 
源代码9 项目: ranger   文件: ServiceRESTUtil.java
static private List<RangerPolicy.RangerPolicyItem> mergePolicyItems(List<RangerPolicy.RangerPolicyItem> policyItems) {
	List<RangerPolicy.RangerPolicyItem> ret = new ArrayList<RangerPolicy.RangerPolicyItem>();

	if (CollectionUtils.isNotEmpty(policyItems)) {
		Map<String, RangerPolicy.RangerPolicyItem> matchedPolicyItems = new HashMap<String, RangerPolicy.RangerPolicyItem>();

		for (RangerPolicy.RangerPolicyItem policyItem : policyItems) {
			if((CollectionUtils.isEmpty(policyItem.getUsers()) && CollectionUtils.isEmpty(policyItem.getGroups()) && CollectionUtils.isEmpty(policyItem.getRoles())) ||
			   (CollectionUtils.isEmpty(policyItem.getAccesses()) && !policyItem.getDelegateAdmin())) {
				continue;
			}

			if (policyItem.getConditions().size() > 1) {
				ret.add(policyItem);
				continue;
			}
			TreeSet<String> accesses = new TreeSet<String>();

			for (RangerPolicy.RangerPolicyItemAccess access : policyItem.getAccesses()) {
				accesses.add(access.getType());
			}
			if (policyItem.getDelegateAdmin()) {
				accesses.add("delegateAdmin");
			}

			String allAccessesString = accesses.toString();

			RangerPolicy.RangerPolicyItem matchingPolicyItem = matchedPolicyItems.get(allAccessesString);

			if (matchingPolicyItem != null) {
				addDistinctItems(policyItem.getUsers(), matchingPolicyItem.getUsers());
				addDistinctItems(policyItem.getGroups(), matchingPolicyItem.getGroups());
				addDistinctItems(policyItem.getRoles(), matchingPolicyItem.getRoles());
			} else {
				matchedPolicyItems.put(allAccessesString, policyItem);
			}
		}

		for (Map.Entry<String, RangerPolicy.RangerPolicyItem> entry : matchedPolicyItems.entrySet()) {
			ret.add(entry.getValue());
		}
	}

	return ret;
}