Java 8 HashSet - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 HashSet class.

This code example shows how to use the following methods:
import play.db.jpa.Model; 
 
@Entity 
public class CompositeIdForeignB extends Model { 
	@OneToMany(mappedBy = "compositeIdForeignB", fetch = FetchType.LAZY) 
	public Set<CompositeIdEntity> a2Bs = new HashSet<CompositeIdEntity>(); 
 
	public String testId; 
} 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add, iterator, size
 
      return new Gson().fromJson(serialized, type);
    } 
 
    public static void putRecentlyUsed(Context context, String asset) {
      LinkedHashSet<String> recentlyUsed = new LinkedHashSet<String>(getRecentlyUsed(context));
      recentlyUsed.add(asset);
 
      if (recentlyUsed.size() > 10) {
        Iterator<String> iterator = recentlyUsed.iterator();
        iterator.next();
        iterator.remove();
      } 
 
      String serialized = new Gson().toJson(recentlyUsed);
      PreferenceManager.getDefaultSharedPreferences(context)
                       .edit()
                       .putString(EMOJI_LRU_PREFERENCE, serialized)
                       .commit();
    } 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
import play.db.jpa.Model; 
 
@Entity 
public class CompositeIdForeignA extends Model { 
	@OneToMany(mappedBy = "compositeIdForeignA", fetch = FetchType.LAZY) 
	public Set<CompositeIdEntity> a2Bs = new HashSet<CompositeIdEntity>(); 
	 
	public String testId; 
} 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
    private final FragmentManager fragmentManager;
 
    private final Resources resources;
 
    private final Set<String> tags = new HashSet<String>();
 
    /** 
     * @param activity 
     * @param defaultUser 
     */ 
    public HomePagerAdapter(final SherlockFragmentActivity activity,
            final boolean defaultUser) {
        super(activity);
 
        fragmentManager = activity.getSupportFragmentManager();
        resources = activity.getResources();
        this.defaultUser = defaultUser;
    } 
 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add
    @Test 
    public void smembers() { 
        jedis.sadd("foo", "a"); 
        jedis.sadd("foo", "b"); 
 
        Set<String> expected = new HashSet<String>();
        expected.add("a");
        expected.add("b");
 
        Set<String> members = jedis.smembers("foo");
 
        assertEquals(expected, members);
 
        // Binary 
        jedis.sadd(bfoo, ba);
        jedis.sadd(bfoo, bb);
 
        Set<byte[]> bexpected = new HashSet<byte[]>();
        bexpected.add(bb);
        bexpected.add(ba);
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add
     */ 
    @Test 
    public void testCreateSection() { 
        Configuration config = getConfig();
 
        Set<String> set = new HashSet<String>();
        set.add("this");
        set.add("this.test.sub");
        set.add("this.test");
        set.add("this.test.other");
 
        config.createSection("this.test.sub");
        config.createSection("this.test.other");
 
        assertEquals(set, config.getKeys(true));
    } 
 
    /** 
     * Test of getDefaults method, of class Configuration. 
     */ 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add
     */ 
    public static final String HEADER_NAME = "X-Requested-By";
 
    private static final Set<String> METHODS_TO_IGNORE;
    static { 
        HashSet<String> mti = new HashSet<String>();
        mti.add("GET");
        mti.add("OPTIONS");
        mti.add("HEAD");
        METHODS_TO_IGNORE = Collections.unmodifiableSet(mti);
    } 
 
    @Override 
    public void filter(ContainerRequestContext rc) throws IOException {
        if (!METHODS_TO_IGNORE.contains(rc.getMethod()) && !rc.getHeaders().containsKey(HEADER_NAME)) {
            throw new BadRequestException(); 
        } 
    } 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add
            if (e1 == s.e1 || e1 == s.e2) { // this in included in s
                return s;
            } 
        } 
        // here we know that there are at least 3 distinct elements 
        HashSet<E> r = new HashSet<E>(4);
        r.add(e1);
        if (e2 != null) {
            r.add(e2);
        } 
        r.add(s.e1);
        if (s.e2 != null) {
            r.add(s.e2);
        } 
        return r;
    } 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add
 
  @Test 
  public void testAllow() 
  { 
 
    HashSet<Integer> sources = new HashSet<Integer>();
    sources.add(23);
    sources.add(45);
    DbusEvent e = RngUtils.randomEvent((short) 23);
    LOG.debug(e);
    SourceDbusFilter sdFilter = new SourceDbusFilter(sources);
    assertTrue(sdFilter.allow(e));
  } 
 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
public class SetConfig extends CollectionConfig { 
    private static final long serialVersionUID = 1L; 
 
    @Override 
    protected Collection<Object> createDefaultInstance() { 
        return new HashSet<Object>(); 
    } 
} 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 HashSet Questions & Answers:

See Code Examples for Java 8 HashSet Methods: