SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SubsetStack.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) 2012 Heiko Strathmann
8  */
9 
10 #ifndef __SUBSETSTACK_H_
11 #define __SUBSETSTACK_H_
12 
13 #include <shogun/lib/config.h>
14 
15 #include <shogun/base/SGObject.h>
18 #include <shogun/features/Subset.h>
19 
20 
21 namespace shogun
22 {
23 
37 class CSubsetStack: public CSGObject
38 {
39 public:
42  CSubsetStack();
43 
46  CSubsetStack(const CSubsetStack& other);
47 
49  virtual ~CSubsetStack();
50 
52  inline const char* get_name() const { return "SubsetStack"; }
53 
62  virtual void add_subset(SGVector<index_t> subset);
63 
71  virtual void add_subset_in_place(SGVector<index_t> subset);
72 
74  virtual void remove_subset();
75 
77  virtual void remove_all_subsets();
78 
80  inline index_t get_size() const
81  {
82  if (!has_subsets())
83  SG_WARNING("CSubsetStack::get_size(): No subset in stack!\n")
84 
85  return has_subsets() ? m_active_subset->get_size() : -1;
86  }
87 
89  virtual bool has_subsets() const
90  {
91  return m_active_subsets_stack->get_num_elements();
92  }
93 
98  CSubset* get_last_subset() const { return m_active_subset; }
99 
106  {
107  return m_active_subset ? m_active_subset->m_subset_idx.vector[idx] : idx;
108  }
109 
110 private:
112  void init();
113 
114 private:
119  CDynamicObjectArray* m_active_subsets_stack;
120 
122  CSubset* m_active_subset;
123 };
124 
125 }
126 #endif /* __SUBSETSTACK_H_ */

SHOGUN Machine Learning Toolbox - Documentation