/* Copyright 1993-2002 The MathWorks, Inc. */ /* Source file for reducep MEX file */ /* $Revision: 1.4 $ */ #ifndef GFXTOOLS_BUFFER_INCLUDED // -*- C++ -*- #define GFXTOOLS_BUFFER_INCLUDED #include "Array.h" template class buffer : public array { protected: int fill; public: buffer() { init(8); } buffer(int l) { init(l); } inline void init(int l) { array::init(l); fill=0; } inline int add(const T& t); inline void reset(); inline int find(const T&); inline T remove(int i); inline int addAll(const buffer& buf); inline void removeDuplicates(); inline int length() const { return fill; } inline int maxLength() const { return array::len; } //array:: added here and 9 other places in this file //because hp700 compiler complaining }; template inline int buffer::add(const T& t) { if( fill == array::len ) resize( array::len*2 ); array::data[fill] = t; return fill++; } template inline void buffer::reset() { fill = 0; } template inline int buffer::find(const T& t) { for(int i=0;i::data[i] == t ) return i; return -1; } template inline T buffer::remove(int i) { #ifdef SAFETY assert( i>=0 ); assert( i::data[i]; array::data[i] = array::data[fill]; return temp; } template inline int buffer::addAll(const buffer& buf) { for(int i=0; i inline void buffer::removeDuplicates() { for(int i=0; i::data[j] ==array:: data[i] ) remove(j); else j++; } } } // GFXTOOLS_BUFFER_INCLUDED #endif