Vowpal Wabbit
unique_sort.cc
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 #include "example.h"
7 #include "unique_sort.h"
8 #include <algorithm>
9 
10 void unique_features(features& fs, int max)
11 {
12  if (fs.indicies.empty())
13  return;
14 
16  features::iterator_all last_index = range.begin();
17  features::iterator_all end = max > 0 ? range.begin() + std::min(fs.size(), (size_t)max) : range.end();
18 
19  for (features::iterator_all i = ++range.begin(); i != end; ++i)
20  if (i.index() != last_index.index())
21  if (i != ++last_index)
22  {
23  last_index.value() = i.value();
24  last_index.index() = i.index();
25  if (!fs.space_names.empty())
26  last_index.audit() = i.audit();
27  }
28 
29  ++last_index;
30  fs.truncate_to(last_index);
31 }
32 
33 void unique_sort_features(uint64_t parse_mask, example* ae)
34 {
35  for (features& fs : *ae)
36  if (fs.sort(parse_mask))
37  unique_features(fs);
38 
39  ae->sorted = true;
40 }
void unique_sort_features(uint64_t parse_mask, example *ae)
Definition: unique_sort.cc:33
v_array< feature_index > indicies
features_value_index_audit_range values_indices_audit()
the core definition of a set of features.
void truncate_to(const features_value_iterator &pos)
size_t size() const
defines a "range" usable by C++ 11 for loops
iterator over values, indicies and audit space names
v_array< audit_strings_ptr > space_names
bool empty() const
Definition: v_array.h:59
void unique_features(features &fs, int max)
Definition: unique_sort.cc:10
feature_value & value()
Definition: feature_group.h:71