Code example for TreeSet

Methods: addcontains

0
    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);
        } 
    }