CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _lucene_util_Array_ 00008 #define _lucene_util_Array_ 00009 00010 CL_NS_DEF(util) 00011 00012 template<typename T> 00013 class CLUCENE_EXPORT Array: LUCENE_BASE{ 00014 public: 00015 T* values; 00016 size_t length; 00017 00018 void deleteAll(){ 00019 for (size_t i=0;i<length;i++) 00020 _CLDELETE(values[i]); 00021 _CLDELETE_ARRAY(values); 00022 } 00023 void deleteArray(){ 00024 _CLDELETE_ARRAY(values); 00025 } 00026 00027 Array(){ 00028 values = NULL; 00029 length = 0; 00030 } 00031 Array(T* values, size_t length){ 00032 this->values = values; 00033 this->length = length; 00034 } 00035 Array(size_t length){ 00036 this->values = _CL_NEWARRAY(T,length); 00037 this->length = length; 00038 } 00039 ~Array(){} 00040 00041 const T operator[](size_t _Pos) const 00042 { 00043 if (length <= _Pos){ 00044 _CLTHROWA(CL_ERR_IllegalArgument,"vector subscript out of range"); 00045 } 00046 return (*(values + _Pos)); 00047 } 00048 T operator[](size_t _Pos) 00049 { 00050 if (length <= _Pos){ 00051 _CLTHROWA(CL_ERR_IllegalArgument,"vector subscript out of range"); 00052 } 00053 return (*(values + _Pos)); 00054 } 00055 00056 }; 00057 00058 CL_NS_END 00059 #endif