From: <laz...@us...> - 2004-02-26 20:47:01
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20352 Added Files: TArray.h Log Message: Added TArray :) --- NEW FILE: TArray.h --- /** * * RTK * Fast and easy cross-platform GUI ToolKit. * * Copyright (C) 2001-200x RTK Development Team * * This library is free software; you can redistribute it and/or modify it * under the terms of the slightly modified (see the "EXCEPTION NOTICE" part * of RTK Library License) GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License * and along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA . * * Also you should have received a copy of RTK Library License, if not please * write an e-mail to some of RTK authors (listed in file AUTHORS). * * Bug reports: bu...@rt... * Suggestions: rf...@rt... ***************************************************************************/ /** * $Source: /cvsroot/rtk/rtk/rtk/TArray.h,v $ ***** * Authors (chronological order): * Mikko Lahteenmaki, mikko§rtk.cx * Contributors (chronological order): * $fname $lname, $email ***** * T0D0 List: * - ***************************************************************************/ #ifndef _RTK_TARRAY_H_ #define _RTK_TARRAY_H_ 1 #include "Array.h" namespace Rtk { /** Template based array around Rtk::Array */ template <class T> class RTK_API TArray : public Array { public: typedef T type; TArray() : Array(sizeof(type)) { } const type *bsearch(const type *key, CmpFunction cmpfunc) { Array::bsearch(ARRAY_DATA(key), cmpfunc); } const type *lfind(const type *key, CmpFunction cmpfunc) { Array::lfind(ARRAY_DATA(key), cmpfunc); } void Append(const type &item) { Array::Append(ARRAY_DATA(&item), 1); } void Append(const type *item, uint elements = 1) { Array::Append(ARRAY_DATA(item), elements); } void Prepend(const type &item) { Array::Prepend(ARRAY_DATA(&item), 1); } void Prepend(const type *item, uint elements=1) { Array::Prepend(ARRAY_DATA(item), elements); } void Insert(uint index, const type &item) { Array::Insert(index, ARRAY_DATA(&item), 1); } void Insert(uint index, const type *item, uint elements = 1) { Array::Insert(index, ARRAY_DATA(item), elements); } void Replace(uint index, const type &item) { Array::Replace(index, ARRAY_DATA(&item), 1); } void Replace(uint index, const type *item, uint elements = 1) { Array::Replace(index, ARRAY_DATA(item), elements); } int Contains(const type &item) const { return Array::Contains(ARRAY_DATA(&item)); } int IndexOf(const type &item) const { return Array::IndexOf(ARRAY_DATA(&item)); } type *Data() { return (type*)Array::Data(); } const type *Data() const { return (const type*)Array::Data(); } type &GetAt(uint index) { return *(type*)Array::GetAt(index); } const type &GetAt(uint index) const { return *(const type*)Array::GetAt(index); } type &operator [](unsigned ind) { return GetAt(ind); } const type &operator [](unsigned ind) const { return GetAt(ind); } }; }; // Rtk namespace #endif /** * $Id: TArray.h,v 1.1 2004/02/26 20:31:01 laza2000 Exp $ ***************************************************************************/ |