WireThread.java :  » Science » logisim-2.3.4 » com » cburch » logisim » circuit » Java Open Source

Java Open Source » Science » logisim 2.3.4 
logisim 2.3.4 » com » cburch » logisim » circuit » WireThread.java
/* Copyright (c) 2006, 2010, Carl Burch. License information is located in the
 * com.cburch.logisim.Main source code and at www.cburch.com/logisim/. */
 
package com.cburch.logisim.circuit;

import com.cburch.logisim.util.SmallSet;

class WireThread {
    private WireThread parent;
    private SmallSet bundles = new SmallSet();

    WireThread() {
        parent = this;
    }

    SmallSet getBundles() {
        return bundles;
    }

    void unite(WireThread other) {
        WireThread group = this.find();
        WireThread group2 = other.find();
        if(group != group2) group.parent = group2;
    }

    WireThread find() {
        WireThread ret = this;
        if(ret.parent != ret) {
            do ret = ret.parent; while(ret.parent != ret);
            this.parent = ret;
        }
        return ret;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.