DynamicArrayPtr.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2009 Soeren Sonnenburg
00008  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _DYNAMIC_ARRAY_PTR_H_
00012 #define _DYNAMIC_ARRAY_PTR_H_
00013 
00014 #include "base/SGObject.h"
00015 #include "base/DynArray.h"
00016 #include "base/Parameter.h"
00017 
00018 namespace shogun
00019 {
00028 class CDynamicArrayPtr :public CSGObject
00029 {
00030     DynArray<CSGObject*> m_array;
00031 
00032     public:
00037         CDynamicArrayPtr(int32_t p_resize_granularity=128)
00038         : CSGObject()
00039         {
00040             m_parameters->add_vector(&m_array.array,
00041                                      &m_array.num_elements, "array",
00042                                      "Memory for dynamic array.");
00043             m_parameters->add(&m_array.last_element_idx,
00044                               "last_element_idx",
00045                               "Element with largest index.");
00046             m_parameters->add(&m_array.resize_granularity,
00047                               "resize_granularity",
00048                               "shrink/grow step size.");
00049         }
00050 
00051         virtual ~CDynamicArrayPtr() {}
00052 
00058         inline int32_t set_granularity(int32_t g)
00059         { return m_array.set_granularity(g); }
00060 
00065         inline int32_t get_array_size(void)
00066         { return m_array.get_array_size(); }
00067 
00072         inline int32_t get_num_elements(void) const
00073         { return m_array.get_num_elements(); }
00074 
00082         inline CSGObject* get_element(int32_t index) const
00083         { return m_array.get_element(index); }
00084 
00092         inline CSGObject* get_element_safe(int32_t index) const
00093         { return m_array.get_element_safe(index); }
00094 
00101         inline bool set_element(CSGObject* element, int32_t index)
00102         { return m_array.set_element(element, index); }
00103 
00110         inline bool insert_element(CSGObject* element, int32_t index)
00111         { return m_array.insert_element(element, index); }
00112 
00118         inline bool append_element(CSGObject* element)
00119         { return m_array.append_element(element); }
00120 
00126         inline void push_back(CSGObject* element)
00127         { m_array.push_back(element); }
00128 
00132         inline void pop_back(void)
00133         { m_array.pop_back(); }
00134 
00140         inline CSGObject* back(void)
00141         { return m_array.back(); }
00142 
00149         inline int32_t find_element(CSGObject* element)
00150         { return m_array.find_element(element); }
00151 
00158         inline bool delete_element(int32_t idx)
00159         { return m_array.delete_element(idx); }
00160 
00166         inline bool resize_array(int32_t n)
00167         { return m_array.resize_array(n); }
00168 
00176         inline CSGObject** get_array(void)
00177         { return m_array.get_array(); }
00178 
00185         inline void set_array(
00186             CSGObject** p_array, int32_t p_num_elements,
00187             int32_t array_size)
00188         { m_array.set_array(p_array, p_num_elements, array_size); }
00189 
00191         inline void clear_array(void)
00192         { m_array.clear_array(); }
00193 
00203         inline CSGObject* operator[](int32_t index) const
00204         { return m_array[index]; }
00205 
00211         inline CDynamicArrayPtr& operator=(CDynamicArrayPtr& orig)
00212         {
00213             m_array = orig.m_array;
00214             return *this;
00215         }
00216 
00218         inline virtual const char* get_name() const
00219         { return "DynamicArrayPtr"; }
00220 };
00221 }
00222 #endif /* _DYNAMIC_ARRAY_PTR_H_  */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation