Vowpal Wabbit
example_predict.h
Go to the documentation of this file.
1 /*
2 Copyright (c) by respective owners including Yahoo!, Microsoft, and
3 individual contributors. All rights reserved. Released under a BSD
4 license as described in the file LICENSE.
5 */
6 #pragma once
7 
8 typedef unsigned char namespace_index;
9 
10 #include "v_array.h"
11 #include "feature_group.h"
12 #include "constant.h"
13 #include <vector>
14 #include <array>
15 
17 {
18  class iterator
19  {
22 
23  public:
24  iterator(features* feature_space, namespace_index* index) : _feature_space(feature_space), _index(index) {}
25 
26  features& operator*() { return _feature_space[*_index]; }
27 
29  {
30  _index++;
31  return *this;
32  }
33 
34  namespace_index index() { return *_index; }
35 
36  bool operator==(const iterator& rhs) { return _index == rhs._index; }
37  bool operator!=(const iterator& rhs) { return _index != rhs._index; }
38  };
39 
41  std::array<features, NUM_NAMESPACES> feature_space; // Groups of feature values.
42  uint64_t ft_offset; // An offset for all feature values.
43 
44  // Interactions are specified by this vector of strings, where each string is an interaction and each char is a
45  // namespace.
46  std::vector<std::string>* interactions;
47 
48  iterator begin() { return iterator(feature_space.data(), indices.begin()); }
49  iterator end() { return iterator(feature_space.data(), indices.end()); }
50 };
51 
52 // make sure we have an exception safe version of example_predict
54 {
55  public:
58 
59  void clear();
60 };
bool operator==(const iterator &rhs)
v_array< namespace_index > indices
namespace_index * _index
std::vector< std::string > * interactions
the core definition of a set of features.
bool operator!=(const iterator &rhs)
T *& begin()
Definition: v_array.h:42
namespace_index index()
std::array< features, NUM_NAMESPACES > feature_space
unsigned char namespace_index
T *& end()
Definition: v_array.h:43
iterator(features *feature_space, namespace_index *index)
iterator begin()