com.expleague.ml.data.set.DataSet Maven / Gradle / Ivy
package com.expleague.ml.data.set;
import com.expleague.commons.func.CacheHolder;
import com.expleague.commons.func.ScopedCache;
import com.expleague.commons.seq.Seq;
import com.expleague.ml.meta.DataSetMeta;
/**
* User: solar
* Date: 26.12.10
* Time: 17:22
*/
public interface DataSet- extends Seq
- , CacheHolder {
DataSetMeta meta();
int index(Item it);
DataSet> parent();
abstract class Stub
extends Seq.Stub implements DataSet {
public ScopedCache cache = new ScopedCache(getClass(), this);
private final DataSet> parent;
protected Stub(final DataSet> parent) {
this.parent = parent;
}
@Override
public ScopedCache cache() {
return cache;
}
@Override
public DataSetMeta meta() {
return parent.meta();
}
@Override
public int index(final T obj) {
for (int i = 0; i < length(); i++) {
if (at(i).equals(obj))
return i;
}
throw new RuntimeException("Object is not in dataset");
}
@Override
public final boolean isImmutable() {
return true;
}
@Override
public final DataSet> parent() {
return parent;
}
}
}