MOA 12.03
Real Time Analytics for Data Streams
CachedInstancesStream.java
Go to the documentation of this file.
00001 /*
00002  *    CachedInstancesStream.java
00003  *    Copyright (C) 2007 University of Waikato, Hamilton, New Zealand
00004  *    @author Richard Kirkby (rkirkby@cs.waikato.ac.nz)
00005  *
00006  *    This program is free software; you can redistribute it and/or modify
00007  *    it under the terms of the GNU General Public License as published by
00008  *    the Free Software Foundation; either version 3 of the License, or
00009  *    (at your option) any later version.
00010  *
00011  *    This program is distributed in the hope that it will be useful,
00012  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *    GNU General Public License for more details.
00015  *
00016  *    You should have received a copy of the GNU General Public License
00017  *    along with this program. If not, see <http://www.gnu.org/licenses/>.
00018  *    
00019  */
00020 package moa.streams;
00021 
00022 import moa.AbstractMOAObject;
00023 import moa.core.InstancesHeader;
00024 import weka.core.Instance;
00025 import weka.core.Instances;
00026 
00035 public class CachedInstancesStream extends AbstractMOAObject implements
00036                 InstanceStream {
00037 
00038         private static final long serialVersionUID = 1L;
00039 
00040         protected Instances toStream;
00041 
00042         protected int streamPos;
00043 
00044         public CachedInstancesStream(Instances toStream) {
00045                 this.toStream = toStream;
00046         }
00047 
00048     @Override
00049         public InstancesHeader getHeader() {
00050                 return new InstancesHeader(this.toStream);
00051         }
00052 
00053     @Override
00054         public long estimatedRemainingInstances() {
00055                 return this.toStream.numInstances() - this.streamPos;
00056         }
00057 
00058     @Override
00059         public boolean hasMoreInstances() {
00060                 return this.streamPos < this.toStream.numInstances();
00061         }
00062 
00063     @Override
00064         public Instance nextInstance() {
00065                 return this.toStream.instance(this.streamPos++);
00066         }
00067 
00068     @Override
00069         public boolean isRestartable() {
00070                 return true;
00071         }
00072 
00073     @Override
00074         public void restart() {
00075                 this.streamPos = 0;
00076         }
00077 
00078     @Override
00079         public void getDescription(StringBuilder sb, int indent) {
00080                 // TODO Auto-generated method stub
00081 
00082         }
00083 
00084 }
 All Classes Namespaces Files Functions Variables Enumerations