SHOGUN  v3.0.0
 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/base/SGObject.h>
16 #include <shogun/features/Subset.h>
17 
18 
19 namespace shogun
20 {
21 
35 class CSubsetStack: public CSGObject
36 {
37 public:
40  CSubsetStack();
41 
44  CSubsetStack(const CSubsetStack& other);
45 
47  virtual ~CSubsetStack();
48 
50  inline const char* get_name() const { return "SubsetStack"; }
51 
55  virtual void add_subset(SGVector<index_t> subset);
56 
58  virtual void remove_subset();
59 
61  virtual void remove_all_subsets();
62 
64  inline index_t get_size() const
65  {
66  if (!has_subsets())
67  SG_WARNING("CSubsetStack::get_size(): No subset in stack!\n")
68 
69  return has_subsets() ? m_active_subset->get_size() : -1;
70  }
71 
73  virtual bool has_subsets() const
74  {
75  return m_active_subsets_stack->get_num_elements();
76  }
77 
82  CSubset* get_last_subset() const { return m_active_subset; }
83 
90  {
91  return m_active_subset ? m_active_subset->m_subset_idx.vector[idx] : idx;
92  }
93 
94 private:
96  void init();
97 
98 private:
103  CDynamicObjectArray* m_active_subsets_stack;
104 
106  CSubset* m_active_subset;
107 };
108 
109 }
110 #endif /* __SUBSETSTACK_H_ */

SHOGUN Machine Learning Toolbox - Documentation