CLAM-Development  1.4.0
Array.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #include "Array.hxx"
23 
24 namespace CLAM
25 {
26 #define CLAM_NUMERIC_ARRAY_INITIALIZATION(Type) \
27 template<> \
28 inline void Array<Type>::InitializeElement(int i) \
29 { \
30  mpData[i]=0; \
31 } \
32 
33 
44 
45 
48 #define CLAM_FAST_ARRAY_SPECIALIZATIONS(TYPE) \
49 template<> \
50 inline void Array<TYPE >::CopyDataBlock(int first, int last, \
51  const TYPE *src) \
52 { \
53  if (last>first) \
54  memcpy(&mpData[first],&src[first], \
55  sizeof(TYPE)*(last-first)); \
56 } \
57 template<> \
58 inline void Array<TYPE >::InitializeCopyDataBlock(int first, int last, \
59  const TYPE *src) \
60 { \
61  if (last>first) \
62  memcpy(&mpData[first],&src[first], \
63  sizeof(TYPE)*(last-first)); \
64 } \
65 template<> \
66 inline void Array<TYPE >::InitializeCopyDataBlock(int first, int last, \
67  int src_first, \
68  const TYPE *src) \
69 { \
70  if (last>first) \
71  memcpy(&mpData[first],&src[src_first], \
72  sizeof(TYPE)*(last-first)); \
73 } \
74 template<> \
75 inline void Array<TYPE >::ResizeDataBuffer(int new_size) \
76 { \
77  mpData = (TYPE*) realloc(mpData,new_size*sizeof(TYPE)); \
78 } \
79 template<> \
80 inline void Array<TYPE >::InsertElemInDataBuffer(int where) \
81 { \
82  memmove(&mpData[where+1],&mpData[where], \
83  (mSize-where)*sizeof(TYPE)); \
84 } \
85 template<> \
86 inline void Array<TYPE >::DeleteElemInDataBuffer(int where) \
87 { \
88  memmove(&mpData[where],&mpData[where+1], \
89  (mSize-where-1)*sizeof(TYPE)); \
90 } \
91 
94 CLAM_FAST_ARRAY_SPECIALIZATIONS(unsigned short)
102 
103 
104 }
105