SHOGUN
v3.2.0
|
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) 2012 Heiko Strathmann 00008 */ 00009 00010 #ifndef __SUBSETSTACK_H_ 00011 #define __SUBSETSTACK_H_ 00012 00013 #include <shogun/base/SGObject.h> 00014 #include <shogun/mathematics/Math.h> 00015 #include <shogun/lib/DynamicObjectArray.h> 00016 #include <shogun/features/Subset.h> 00017 00018 00019 namespace shogun 00020 { 00021 00035 class CSubsetStack: public CSGObject 00036 { 00037 public: 00040 CSubsetStack(); 00041 00044 CSubsetStack(const CSubsetStack& other); 00045 00047 virtual ~CSubsetStack(); 00048 00050 inline const char* get_name() const { return "SubsetStack"; } 00051 00055 virtual void add_subset(SGVector<index_t> subset); 00056 00058 virtual void remove_subset(); 00059 00061 virtual void remove_all_subsets(); 00062 00064 inline index_t get_size() const 00065 { 00066 if (!has_subsets()) 00067 SG_WARNING("CSubsetStack::get_size(): No subset in stack!\n") 00068 00069 return has_subsets() ? m_active_subset->get_size() : -1; 00070 } 00071 00073 virtual bool has_subsets() const 00074 { 00075 return m_active_subsets_stack->get_num_elements(); 00076 } 00077 00082 CSubset* get_last_subset() const { return m_active_subset; } 00083 00089 inline index_t subset_idx_conversion(index_t idx) const 00090 { 00091 return m_active_subset ? m_active_subset->m_subset_idx.vector[idx] : idx; 00092 } 00093 00094 private: 00096 void init(); 00097 00098 private: 00103 CDynamicObjectArray* m_active_subsets_stack; 00104 00106 CSubset* m_active_subset; 00107 }; 00108 00109 } 00110 #endif /* __SUBSETSTACK_H_ */