00001 /*=====================================================================
00002 File: cvector.h
00003 Purpose:
00004 Revision: $Id: cvector.h,v 1.2 2002/05/13 21:07:45 philosophil Exp $
00005 Created by: Philippe Lavoie (3 Oct, 1996)
00006 Modified by:
00007 Copyright notice:
00008 Copyright (C) 1996-1998 Philippe Lavoie
00009
00010 This library is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU Library General Public
00012 License as published by the Free Software Foundation; either
00013 version 2 of the License, or (at your option) any later version.
00014
00015 This library is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018 Library General Public License for more details.
00019
00020 You should have received a copy of the GNU Library General Public
00021 License along with this library; if not, write to the Free
00022 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00023 =====================================================================*/
00024
00025 #ifndef _Matrix_cvector_h_
00026 #define _Matrix_cvector_h_
00027
00028
00029
00030 #include <math.h>
00031 #include "vector.h"
00032
00033 namespace PLib {
00034
00047 template<class T> class CVector : public Vector<T>
00048 {
00049 public:
00050 CVector() : Vector<T>(), index(0) {;}
00051 CVector(const int r) : Vector<T>(r), index(0) {;}
00052 CVector(const CVector<T>& v) : Vector<T>(v), index(v.index) {;}
00053 CVector(const Vector<T>& v) : Vector<T>(v), index(0) {;}
00054 CVector(const BasicArray<T>& v) : Vector<T>(v), index(0) {;}
00055 virtual ~CVector() {}
00056
00057 T& operator[](const int i) { return x[i%sze]; }
00058 T operator[](const int i) const { return x[i%sze]; }
00059
00060 void put(T v) { x[index] = v ; index = (index+1)%sze; }
00061
00062 protected:
00063 int index ;
00064
00065 };
00066
00067 } // end namespace
00068
00069 typedef PLib::CVector<int> CVector_INT ;
00070 typedef PLib::CVector<char> CVector_BYTE ;
00071 typedef PLib::CVector<float> CVector_FLOAT ;
00072 typedef PLib::CVector<double> CVector_DOUBLE ;
00073 typedef PLib::CVector<unsigned char> CVector_UBYTE ;
00074
00075 #endif
1.2.14 written by Dimitri van Heesch,
© 1997-2002