PLearn 0.1
Public Member Functions | Protected Attributes
PLearn::InMemoryIntStream Class Reference

#include <IntStream.h>

Inheritance diagram for PLearn::InMemoryIntStream:
Inheritance graph
[legend]
Collaboration diagram for PLearn::InMemoryIntStream:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 InMemoryIntStream (IntStream &stream)
 copy stream to memory
virtual void seek (long position)
 move to given position
virtual int next ()
 return currently available int from the stream (at currente position) and THEN increment position to NEXT item
virtual int current ()
 return next available int from the stream
virtual long size ()
 total length of the stream
virtual ~InMemoryIntStream ()

Protected Attributes

intdata
int length

Detailed Description

Definition at line 162 of file IntStream.h.


Constructor & Destructor Documentation

PLearn::InMemoryIntStream::InMemoryIntStream ( IntStream stream)

copy stream to memory

Definition at line 267 of file IntStream.cc.

References data, i, length, PLearn::IntStream::next(), and PLearn::IntStream::size().

{
    length = stream.size();
    data = new int[length];
    for (int i=0;i<length;i++)
        data[i] = stream.next();
}

Here is the call graph for this function:

virtual PLearn::InMemoryIntStream::~InMemoryIntStream ( ) [inline, virtual]

Definition at line 188 of file IntStream.h.

{ delete[] data; }

Member Function Documentation

virtual int PLearn::InMemoryIntStream::current ( ) [inline, virtual]

return next available int from the stream

Reimplemented from PLearn::IntStream.

Definition at line 185 of file IntStream.h.

{ return data[pos]; }
virtual int PLearn::InMemoryIntStream::next ( ) [inline, virtual]

return currently available int from the stream (at currente position) and THEN increment position to NEXT item

Reimplemented from PLearn::IntStream.

Definition at line 179 of file IntStream.h.

                       { 
        int v=data[pos];
        pos++;
        if (pos>=length) pos=0;
        return v;
    }
virtual void PLearn::InMemoryIntStream::seek ( long  position) [inline, virtual]

move to given position

Reimplemented from PLearn::IntStream.

Definition at line 171 of file IntStream.h.

References PLERROR.

    { 
        pos = position; 
#ifdef BOUNDCHECK
        if (pos<0 || pos>=length) PLERROR("InMemoryIntStream::seek(%d) out of range (0,%d)",
                                          position,length-1);
#endif
    }
virtual long PLearn::InMemoryIntStream::size ( ) [inline, virtual]

total length of the stream

Reimplemented from PLearn::IntStream.

Definition at line 186 of file IntStream.h.

{ return length; }

Member Data Documentation

Definition at line 164 of file IntStream.h.

Referenced by InMemoryIntStream().

Definition at line 165 of file IntStream.h.

Referenced by InMemoryIntStream().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines