Example usage for java.util TreeSet clone

List of usage examples for java.util TreeSet clone

Introduction

In this page you can find the example usage for java.util TreeSet clone.

Prototype

@SuppressWarnings("unchecked")
public Object clone() 

Source Link

Document

Returns a shallow copy of this TreeSet instance.

Usage

From source file:Main.java

public static void main(String[] args) {
    TreeSet<Integer> tree = new TreeSet<Integer>();

    tree.add(12);//from   www  . j a  va2 s . c om
    tree.add(13);
    tree.add(14);

    // cloning tree into clinetree
    TreeSet<Integer> clonetree = (TreeSet) tree.clone();

    // creating iterator
    Iterator<Integer> iterator = clonetree.iterator();

    while (iterator.hasNext()) {
        System.out.println(iterator.next());
    }
}

From source file:OSFFM_ORC.FederationActionManager.java

private JSONObject bnaNetSegCreate(JSONObject tables, DBMongo m, String refSite, String tenant,
        HashMap<String, Object> updNet) {

    JSONObject bnaSegTab = new JSONObject();
    JSONArray segRow = null;//from   w  w  w .  ja  va  2 s .c o m
    JSONObject subJSON = null;
    Integer version = null;
    UUID uuid = null;
    String fedNet = "";
    //boolean resultIns = false;
    TreeSet<String> fednets = new TreeSet<String>();
    try {
        //fedNet = tables.getString("name");
        version = tables.getInt("version");
        JSONArray bigArray = (JSONArray) tables.get("table");
        //uuid=UUID.randomUUID();
        // JSONArray littleArray;
        for (int i = 0; i < bigArray.length(); i++) {

            uuid = UUID.randomUUID();
            JSONArray innerArray = (JSONArray) bigArray.get(i);
            for (int j = 0; j < innerArray.length(); j++) {

                JSONObject objectJson = (JSONObject) innerArray.get(j);
                fedNet = objectJson.getString("name"); //***ATTENZIONARE PERCHE NEL CASO DI OPENNEBULA LE FEDNET ALL'INTERNO DELL'INNERARRAY POTREBBERO AVERE NOMI DIVERSI DUNQUE SI PER L'INFORMAZIONE
                fednets.add(fedNet);
                bnaSegTab.put("FK", uuid.toString());
                // bnaSegTab.put("fedNet",objectJson.get("name"));
                bnaSegTab.put("netEntry", objectJson);//QUESTO  objectJson: { "tenant_id" : "b0edb3a0ae3842b2a3f3969f07cd82f2", "site_name" : "CETIC", "vnid" : "d46a55d4-6cca-4d86-bf25-f03707680795", "name" : "provider" }
                m.insertNetTables(tenant, bnaSegTab.toString(0));

            }
            m.insertTablesData(uuid.toString(), tenant, version, refSite, fedNet); //ATTENZIONARE VEDI COMMENTO ***
        }
        updNet.put(refSite, fednets.clone());
        Iterator iter = fednets.iterator();
        while (iter.hasNext()) {
            System.out.println(iter.next());
        }
        fednets.clear();
    } catch (JSONException ex) {
        System.out.println("-___-' Error: " + ex.getMessage());
    } catch (MDBIException ex) {
        System.out.println("-___-' Error: " + ex.getMessage());
    }

    return bnaSegTab;
}