SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SGStringList.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 Fernando José Iglesias García
8  * Written (W) 2010,2012 Soeren Sonnenburg
9  * Copyright (C) 2010 Berlin Institute of Technology
10  * Copyright (C) 2012 Soeren Sonnenburg
11  */
12 #ifndef __SGSTRINGLIST_H__
13 #define __SGSTRINGLIST_H__
14 
15 #include <shogun/lib/config.h>
16 #include <shogun/lib/DataType.h>
17 #include <shogun/lib/SGString.h>
18 
19 namespace shogun
20 {
22 template <class T> struct SGStringList
23 {
24 public:
27  do_free(false) { }
28 
30  SGStringList(SGString<T>* s, index_t num_s, index_t max_length,
31  bool free_strings=false) : num_strings(num_s),
32  max_string_length(max_length), strings(s), do_free(free_strings) { }
33 
35  SGStringList(index_t num_s, index_t max_length, bool free_strings=false)
36  : num_strings(num_s), max_string_length(max_length),
37  do_free(free_strings)
38  {
40  }
41 
43  SGStringList(const SGStringList &orig) :
46  strings(orig.strings), do_free(orig.do_free) { }
47 
49  void free_list()
50  {
51  if (do_free)
53 
54  strings=NULL;
55  do_free=false;
56  num_strings=0;
58  }
59 
61  void destroy_list()
62  {
63  do_free=true;
64  free_list();
65  }
66 
67 public:
70 
73 
76 
78  bool do_free;
79 };
80 }
81 #endif // __SGSTRINGLIST_H__

SHOGUN Machine Learning Toolbox - Documentation