SHOGUN
v3.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
lib
GCArray.h
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Written (W) 2009 Soeren Sonnenburg, Fabio De Bona
8
* Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
9
*/
10
11
#ifndef __GCARRAY_H__
12
#define __GCARRAY_H__
13
14
#include <
shogun/base/SGObject.h
>
15
#include <
shogun/lib/common.h
>
16
17
namespace
shogun
18
{
19
#define IGNORE_IN_CLASSLIST
20
28
IGNORE_IN_CLASSLIST
template
<
class
T>
class
CGCArray
:
public
CSGObject
29
{
30
public
:
32
CGCArray
() :
CSGObject
()
33
{
34
SG_UNSTABLE
(
"CGCArray::CGCArray()"
,
"\n"
)
35
36
array
= NULL;
37
size
=0;
38
}
39
44
CGCArray
(int32_t sz) :
CSGObject
()
45
{
46
ASSERT
(sz>0)
47
array
= SG_CALLOC(T, sz);
48
size
=sz;
49
}
50
52
virtual
~CGCArray
()
53
{
54
for
(int32_t i=0; i<
size
; i++)
55
SG_UNREF
(
array
[i]);
56
SG_FREE(
array
);
57
}
58
64
inline
void
set
(T element, int32_t index)
65
{
66
ASSERT
(index>=0)
67
ASSERT
(index<
size
)
68
SG_REF
(element);
69
SG_UNREF
(
array
[index]);
70
array
[index]=element;
71
}
72
78
inline
T
get
(int32_t index)
79
{
80
ASSERT
(index>=0)
81
ASSERT
(index<
size
)
82
T element=
array
[index];
83
SG_REF
(element);
//???
84
return
element;
85
}
86
91
virtual
const
char
*
get_name
()
const
{
return
"GCArray"
; }
92
93
protected
:
95
T*
array
;
97
int32_t
size
;
98
};
99
}
100
#endif //__GCARRAY_H__
SHOGUN
Machine Learning Toolbox - Documentation