TreeSet 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 TreeSet contains method.

This code example shows how to use the following methods:add, contains
    private static Map<Integer, Row> DATA_BY_COLUMN_ID = new HashMap<Integer, Row>();
 
    public static void upsertRow(Row row) {
        TreeSet<Row> byTableRows = DATA_BY_TABLE_ID.get(row.tableId);
        if (byTableRows == null) {
            byTableRows = new TreeSet<Row>();
        } 
        if (!byTableRows.contains(row)) {
            byTableRows.add(row);
        } 
//System.out.println("byTableRows.size()===>"+byTableRows.size()); 
        DATA_BY_TABLE_ID.put(row.tableId, byTableRows);
        DATA_BY_COLUMN_ID.put(row.columnId, row);
    } 
 
    public static void upsertRows(Row[] rows) {
        for (Row row : rows) {
            upsertRow(row);
        } 
    } 
6
CodeRank
This code example shows how to use the following methods:toString, add, clear, contains
    final String retval = (String) this.cache.get(key);
    if (retval != null)
    { 
      return retval;
    } 
    this.lookupPath.clear();
    return internalGetString(key);
  } 
 
  /** 
   * Performs the lookup for the given key. If the key points to a link the 
   * link is resolved and that key is looked up instead. 
   * 
   * @param key the key for the string 
   * @return the string for the given key 
   */ 
  protected String internalGetString(final String key)
  { 
    if (this.lookupPath.contains(key))
    { 

6
CodeRank
This code example shows how to use the following methods:add, contains
        PathTemplate.create(null); 
    } 
 
    @Test
    public void testDetectDuplicates() { 
        final TreeSet<PathTemplate> seen = new TreeSet<>();
        seen.add(PathTemplate.create("/bob/{foo}"));
        Assert.assertTrue(seen.contains(PathTemplate.create("/bob/{ak}")));
        Assert.assertFalse(seen.contains(PathTemplate.create("/bob/{ak}/other")));
    } 
 
    private void testMatch(final String template, final String path, final String ... pathParams)  {
        Assert.assertEquals(0, pathParams.length % 2);
        final Map<String, String> expected = new HashMap<>();
        for(int i = 0; i < pathParams.length; i+=2) {
            expected.put(pathParams[i], pathParams[i+1]);
        } 
        final Map<String, String> params = new HashMap<>();
 
        PathTemplate pathTemplate = PathTemplate.create(template);
6
CodeRank
This code example shows how to use the following methods:add, contains, size
        } 
    } 
 
    public void test_addLjava_lang_Object() { 
        // Test for method boolean java.util.TreeSet.add(java.lang.Object) 
        ts.add(new Integer(-8));
        assertTrue("Failed to add Object", ts.contains(new Integer(-8)));
        ts.add(objArray[0]);
        assertTrue("Added existing element", ts.size() == objArray.length + 1);
 
        HashMap hm = new HashMap();
        hm.put("First", new Integer(1));
        hm.put(new Integer(2), "two");
 
        try { 
            ts.add("Wrong element");
            fail("ClassCastException expected");
        } catch (ClassCastException e) {
            //expected 
        } 
    } 
6
CodeRank
This code example shows how to use the following methods:add, contains, remove
  private IdGenerator(TreeSet<Long> set) {
    this.set = set;
  } 
   
  private void flip(long x) {
    if (set.contains(x))
      set.remove(x);
    else 
      set.add(x);
  } 
   
  public long generate() { 
    Iterator<Long> i = set.iterator();
    if (!i.hasNext()) {
      set.add(0l);
      set.add(1l);
      return 0; 
    } 
     
    long a = i.next(), id;
5
CodeRank
This code example shows how to use the following methods:add, contains
    Coordinate[] coordinates = new Coordinate[list.size()];
    return (Coordinate[]) list.toArray(coordinates);
  } 
 
  public void filter(Coordinate coord) {
    if (!treeSet.contains(coord)) {
      list.add(coord);
      treeSet.add(coord);
    } 
  } 
} 
 
5
CodeRank
This code example shows how to use the following methods:add, contains, isEmpty
     * 添加iptables规则 
     *  
     * @param rule iptables规则 
     */ 
    public void addRule(String rule) {
        if (rules.isEmpty())
            rules.add(IPTABLES_RULE_HTTP);
        if (!rules.contains(rule))
            rules.add(rule);
    } 
 
    /** 
     * 添加所有规则至现有规则列表 
     *  
     * @param newRules 新规则列表 
     */ 
    public void addAllRules(Collection<? extends String> newRules) {
        if (rules.isEmpty())
            rules.add(IPTABLES_RULE_HTTP);
        rules.addAll(newRules);
5
CodeRank
This code example shows how to use the following methods:add, contains
    Coordinate[] coordinates = new Coordinate[list.size()];
    return (Coordinate[]) list.toArray(coordinates);
  } 
 
  public void filter(Coordinate coord) {
    if (!treeSet.contains(coord)) {
      list.add(coord);
      treeSet.add(coord);
    } 
  } 
} 
 
6
CodeRank
This code example shows how to use the following methods:clear, contains, size
	/** 
	 * @tests java.util.TreeSet#clear() 
	 */ 
	public void test_clear() { 
		// Test for method void java.util.TreeSet.clear() 
		ts.clear();
		assertEquals("Returned non-zero size after clear", 0, ts.size());
		assertTrue("Found element in cleared set", !ts.contains(objArray[0]));
	} 
 
	/** 
	 * @tests java.util.TreeSet#clone() 
	 */ 
	public void test_clone() { 
		// Test for method java.lang.Object java.util.TreeSet.clone() 
		TreeSet s = (TreeSet) ts.clone();
		Iterator i = ts.iterator();
		while (i.hasNext())
			assertTrue("Clone failed to copy all elements", s
					.contains(i.next()));
5
CodeRank
This code example shows how to use the following methods:add, contains, remove
m_expanded.add(aID);
	        	} 
	        	else 
	        	{ 
	        		m_expanded.remove(aID);
	        	} 
	        	 
	            v.setArtistID(getCursor().getLong(1));
	             
	            v.setExpandedState(m_expanded.contains(Long.valueOf(getCursor().getLong(1))));
	        } 
	        bindView(v, parent.getContext(), getCursor());
	        v.refreshState();
	       
	        return v;
		     
		} 
		 
		public View newView(Context context, Cursor c, ViewGroup vg)
5
CodeRank
contains Method Overview
Returns true if this set contains the specified element.
See Code Examples for other Java 8 TreeSet Methods: