All Downloads are FREE. Search and download functionalities are using the official Maven repository.

model.MARK_II.generalAlgorithm.SegmentUpdateList Maven / Gradle / Ivy

The newest version!
package model.MARK_II.generalAlgorithm;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author Quinn Liu ([email protected])
 * @version April 25, 2014
 */
public class SegmentUpdateList {
    List segmentUpdateList;

    public SegmentUpdateList() {
        this.segmentUpdateList = new ArrayList();
    }

    public void add(SegmentUpdate segmentUpdate) {
        this.segmentUpdateList.add(segmentUpdate);
    }

    public int size() {
        return this.segmentUpdateList.size();
    }

    public void clear() {
        this.segmentUpdateList.clear();
    }

    public SegmentUpdate getSegmentUpdate(ColumnPosition columnPosition,
                                          int neuronIndex) {
        for (SegmentUpdate segmentUpdate : this.segmentUpdateList) {
            if (segmentUpdate.getNeuronColumnPosition().equals(columnPosition)
                    && segmentUpdate.getNeuronIndex() == neuronIndex) {
                return segmentUpdate;
            }
        }
        return null;
    }

    public boolean deleteSegmentUpdate(ColumnPosition columnPosition,
                                       int neuronIndex) {
        for (int i = 0; i < this.segmentUpdateList.size(); i++) {
            SegmentUpdate currentSegmentUpdate = this.segmentUpdateList.get(i);

            if (currentSegmentUpdate.getNeuronColumnPosition().equals(
                    columnPosition)
                    && currentSegmentUpdate.getNeuronIndex() == neuronIndex) {
                this.segmentUpdateList.remove(i);
                return true;
            }
        }
        return false;
    }

    List getList() {
        return Collections.unmodifiableList(this.segmentUpdateList);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy