HashSet contains - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for HashSet contains method.

This code example shows how to use the following methods:contains
		knownNonces.add(nonce);
		return nonce;
	} 
 
	public static boolean isNonceKnown(long nonce) {
		return knownNonces.contains(nonce);
	} 
 
	public static void removeNonce(long nonce) {
		knownNonces.remove(nonce);
	} 
	 
	public static String obfuscate(Context context, byte[] salt, String original) {
		final AESObfuscator obfuscator = getObfuscator(context, salt);
		return obfuscator.obfuscate(original);
	} 
	 
	private static AESObfuscator _obfuscator = null;
	 
	private static AESObfuscator getObfuscator(Context context, byte[] salt) {
7
CodeRank
This code example shows how to use the following methods:contains
    } 
 
    @Override 
    public boolean has(CommandSender sender, String permission) {
        return (sender instanceof Player)
            ? opCommands.contains(permission)
                ? ((Player) sender).isOp()
                : true 
            : true; 
    } 
    @Override 
    public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
        return null; 
    } 
    @Override 
    public boolean hasOfflinePermission(String player, String perm) {
        return false; 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:add, contains
	private TypeDescriptor resolve(HashSet<String> circularCheck) {
		TypeDescriptor ref = module.getTypeDescriptor(typeref, 0, false);
		if (ref == null) {
			throw new IllegalArgumentException("Unknown type: " + typeref);
		} 
		if (circularCheck.contains(name)) {
			throw new IllegalArgumentException("Circular definition of " + name);
		} 
		circularCheck.add(name);
		if (ref instanceof Typedef) {
			return ((Typedef) ref).resolve(circularCheck);
		} 
		return ref;
	} 
 
	@Override 
	public Class getNativeClass() {
		return resolve().getNativeClass(); 
	} 
 
7
CodeRank
This code example shows how to use the following methods:contains
        ModuleAdminServiceClient moduleAdminServiceClient =
                new ModuleAdminServiceClient(asServer.getBackEndUrl(), asServer.getSessionCookie()); 
 
        ModuleMetaData[] moduleMetaDataArr = moduleAdminServiceClient.getModuleList();
 
        HashSet<String> moduleDataSet = new HashSet<String>(moduleMetaDataArr.length);
 
        for (int x = 0; x < moduleMetaDataArr.length; x++) {
            moduleDataSet.add(moduleMetaDataArr[x].getModulename());
        } 
 
        Assert.assertTrue(moduleDataSet.contains("wso2xfer"));
        Assert.assertTrue(moduleDataSet.contains("rahas"));
        Assert.assertTrue(moduleDataSet.contains("rampart"));
        Assert.assertTrue(moduleDataSet.contains("sandesha2"));
        Assert.assertTrue(moduleDataSet.contains("wso2caching"));
        Assert.assertTrue(moduleDataSet.contains("addressing"));
        Assert.assertTrue(moduleDataSet.contains("wso2mex"));
        Assert.assertTrue(moduleDataSet.contains("wso2throttle"));
 

6
CodeRank
This code example shows how to use the following methods:contains, remove
 
    @Override 
    public void onListItemClick(ListView l, View v, int position, long id) {
        ServiceInfo info = mList.getItem(position);
        final ComponentName cn = new ComponentName(info.packageName, info.name);
        if (mEnabledListeners.contains(cn)) {
            // the simple version: disabling 
            mEnabledListeners.remove(cn);
            saveEnabledListeners(); 
        } else { 
            // show a scary dialog 
            new ListenerWarningDialogFragment() 
                .setListenerInfo(cn, info.loadLabel(mPM).toString())
                .show(getFragmentManager(), "dialog");
        } 
    } 
 
    static class ViewHolder { 
        ImageView icon;
        TextView name;
7
CodeRank
This code example shows how to use the following methods:contains
     
    /** 
     * @see prefuse.data.util.ColumnProjection#include(prefuse.data.column.Column, java.lang.String) 
     */ 
    public boolean include(Column col, String name) {
        return !(m_include ^ m_names.contains(name));
    } 
 
} // end of class NamedColumnProjection 
6
CodeRank
This code example shows how to use the following methods:contains, size
	} 
 
	public void testHashSet() { 
		NSSet<String> set = new NSSet<String>("abc");
		HashSet<String> hashSet = set.hashSet();
		assertEquals(1, hashSet.size());
		assertTrue(hashSet.contains("abc"));
	} 
 
  public void testClone() { 
		NSSet<String> set = new NSSet<String>(new String[] { "abc", "123" });
		NSSet<String> clone = (NSSet<String>) set.clone();
		assertEquals(set, clone);
	} 
 
	public void testImmutableClone() { 
		NSSet<String> set = new NSSet<String>(new String[] { "abc", "123" });
		NSSet<String> clone = set.immutableClone();
		assertEquals(set, clone);
		assertEquals(NSSet.class, clone.getClass());
6
CodeRank
This code example shows how to use the following methods:add, contains
    contents.remove(result); 
    return result; 
  } 
   
  public void insertStatement(AbstractStatement eq) { 
    if (!contents.contains(eq)) { 
      contents.add(eq); 
      super.insert(eq); 
    } 
  } 
 
} 
6
CodeRank
This code example shows how to use the following methods:contains
            mExts.addAll(Arrays.asList(exts));
        } 
    } 
 
    public boolean contains(String ext) {
        return mExts.contains(ext.toLowerCase());
    } 
 
    @Override 
    public boolean accept(File dir, String filename) {
 
        File file = new File(dir + File.separator + filename);
        if (file.isDirectory()) {
            return true; 
        } 
 
        int dotPosition = filename.lastIndexOf('.');
        if (dotPosition != -1) {
            String ext = (String) filename.subSequence(dotPosition + 1, filename.length());
            return contains(ext.toLowerCase());
6
CodeRank
This code example shows how to use the following methods:add, contains, size
	/** 
	 * @tests java.util.LinkedHashSet#add(java.lang.Object) 
	 */ 
	public void test_addLjava_lang_Object() { 
		// Test for method boolean java.util.LinkedHashSet.add(java.lang.Object) 
		int size = hs.size();
		hs.add(new Integer(8));
		assertTrue("Added element already contained by set", hs.size() == size);
		hs.add(new Integer(-9));
		assertTrue("Failed to increment set size after add",
				hs.size() == size + 1);
		assertTrue("Failed to add element to set", hs.contains(new Integer(-9)));
	} 
 
	/** 
	 * @tests java.util.LinkedHashSet#clear() 
	 */ 
	public void test_clear() { 
		// Test for method void java.util.LinkedHashSet.clear() 
		Set orgSet = (Set) hs.clone();
6
CodeRank

Related HashSet contains Questions & Answers:

contains Method Overview
Returns true if this set contains the specified element.
See Code Examples for other Java 8 HashSet Methods: