moa.core.AutoExpandVector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moa Show documentation
Show all versions of moa Show documentation
Massive On-line Analysis is an environment for massive data mining. MOA
provides a framework for data stream mining and includes tools for evaluation
and a collection of machine learning algorithms. Related to the WEKA project,
also written in Java, while scaling to more demanding problems.
/*
* AutoExpandVector.java
* Copyright (C) 2007 University of Waikato, Hamilton, New Zealand
* @author Richard Kirkby ([email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
*/
package moa.core;
import java.util.ArrayList;
import java.util.Collection;
import moa.AbstractMOAObject;
import moa.MOAObject;
/**
* Vector with the capability of automatic expansion.
*
* @author Richard Kirkby ([email protected])
* @version $Revision: 7 $
*/
public class AutoExpandVector extends ArrayList implements MOAObject {
private static final long serialVersionUID = 1L;
public AutoExpandVector() {
super(0);
}
public AutoExpandVector(int size) {
super(size);
}
@Override
public void add(int pos, T obj) {
if (pos > size()) {
while (pos > size()) {
add(null);
}
trimToSize();
}
super.add(pos, obj);
}
@Override
public T get(int pos) {
return ((pos >= 0) && (pos < size())) ? super.get(pos) : null;
}
@Override
public T set(int pos, T obj) {
if (pos >= size()) {
add(pos, obj);
return null;
}
return super.set(pos, obj);
}
@Override
public boolean add(T arg0) {
boolean result = super.add(arg0);
trimToSize();
return result;
}
@Override
public boolean addAll(Collection extends T> arg0) {
boolean result = super.addAll(arg0);
trimToSize();
return result;
}
@Override
public boolean addAll(int arg0, Collection extends T> arg1) {
boolean result = super.addAll(arg0, arg1);
trimToSize();
return result;
}
@Override
public void clear() {
super.clear();
trimToSize();
}
@Override
public T remove(int arg0) {
T result = super.remove(arg0);
trimToSize();
return result;
}
@Override
public boolean remove(Object arg0) {
boolean result = super.remove(arg0);
trimToSize();
return result;
}
@Override
protected void removeRange(int arg0, int arg1) {
super.removeRange(arg0, arg1);
trimToSize();
}
@Override
public MOAObject copy() {
return AbstractMOAObject.copy(this);
}
@Override
public int measureByteSize() {
return AbstractMOAObject.measureByteSize(this);
}
@Override
public void getDescription(StringBuilder sb, int indent) {
// TODO Auto-generated method stub
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy