/usr/include/shogun/lib/GCArray.h is in libshogun-dev 3.2.0-7.3build4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2009 Soeren Sonnenburg, Fabio De Bona
* Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
*/
#ifndef __GCARRAY_H__
#define __GCARRAY_H__
#include <shogun/base/SGObject.h>
#include <shogun/lib/common.h>
namespace shogun
{
#define IGNORE_IN_CLASSLIST
/** @brief Template class GCArray implements a garbage collecting static array
*
* This array is meant to be used for Shogun Objects (CSGObject) only, as it
* deals with garbage collection, i.e. on read and array assignment the
* reference count is increased (and decreased on delete and overwriting
* elements).
*
* */
IGNORE_IN_CLASSLIST template <class T> class CGCArray : public CSGObject
{
public:
/** default constructor */
CGCArray() : CSGObject()
{
SG_UNSTABLE("CGCArray::CGCArray()", "\n")
array = NULL;
size=0;
}
/** Constructor
*
* @param sz length of array
*/
CGCArray(int32_t sz) : CSGObject()
{
ASSERT(sz>0)
array = SG_CALLOC(T, sz);
size=sz;
}
/** Destructor */
virtual ~CGCArray()
{
for (int32_t i=0; i<size; i++)
SG_UNREF(array[i]);
SG_FREE(array);
}
/** write access operator
*
* @param element - element to write
* @param index - index to write to
*/
inline void set(T element, int32_t index)
{
ASSERT(index>=0)
ASSERT(index<size)
SG_REF(element);
SG_UNREF(array[index]);
array[index]=element;
}
/** read only access operator
*
* @param index index to write to
* @return element element
*/
inline T get(int32_t index)
{
ASSERT(index>=0)
ASSERT(index<size)
T element=array[index];
SG_REF(element); //???
return element;
}
/** get the name of the object
*
* @return name of object
*/
virtual const char* get_name() const { return "GCArray"; }
protected:
/// array
T* array;
/// size of array
int32_t size;
};
}
#endif //__GCARRAY_H__
|