SHOGUN  v2.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() {
65  if (!has_subsets())
66  SG_WARNING("CSubsetStack::get_size(): No subset in stack!\n");
67 
68  return has_subsets() ? m_active_subset->get_size() : -1;
69  }
70 
72  inline virtual bool has_subsets() const
73  {
74  return m_active_subsets_stack->get_num_elements();
75  }
76 
81  CSubset* get_last_subset() const { return m_active_subset; }
82 
89  {
90  return m_active_subset ? m_active_subset->m_subset_idx.vector[idx] : idx;
91  }
92 
93 private:
95  void init();
96 
97 private:
102  CDynamicObjectArray* m_active_subsets_stack;
103 
105  CSubset* m_active_subset;
106 };
107 
108 }
109 #endif /* __SUBSETSTACK_H_ */

SHOGUN Machine Learning Toolbox - Documentation