view src/main/java/alice/topology/manager/ParentManager.java @ 476:8968b24c1ce3 dispose

TODO is to fix ParentManager information
author sugi
date Tue, 02 Dec 2014 13:43:07 +0900
parents fac27e395930
children f644dc9e0589
line wrap: on
line source

package alice.topology.manager;

import java.util.ArrayList;

public class ParentManager {

    private int BINARY_TREE = 2;
    private int position = 0;
    private ArrayList<Parent> list;
    public ParentManager(){
        list = new ArrayList<Parent>();
    }

    public String getMyParent() {
        checkChildNumber();
        return list.get(position).getName();
    }

    public int getMyNumber() {
        checkChildNumber();
        int num = list.get(position).children();
        list.get(position).increment();
        return num;
    }

    private void checkChildNumber() {
        for (;;next()) {
            if (list.get(position).children() < BINARY_TREE)
                break;
        }
    }

    public void register(String name) {
        Parent p = new Parent(name);
        list.add(p);
    }

    public void next() {
        position++;
    }

    public void previous() {
        position--;
    }

    public void overwirte(String str, String str1) {

    }
}